OpenMW
libs/openengine/ogre/lights.hpp
Go to the documentation of this file.
00001 #ifndef OENGINE_OGRE_LIGHTS_H
00002 #define OENGINE_OGRE_LIGHTS_H
00003 
00004 #include <OgreController.h>
00005 #include <OgreColourValue.h>
00006 #include <OgreMath.h>
00007 
00008 /*
00009  * Controller classes to handle pulsing and flicker lights
00010  */
00011 
00012 namespace OEngine {
00013 namespace Render {
00014     enum LightType {
00015         LT_Normal,
00016         LT_Flicker,
00017         LT_FlickerSlow,
00018         LT_Pulse,
00019         LT_PulseSlow
00020     };
00021 
00022     class LightFunction : public Ogre::ControllerFunction<Ogre::Real>
00023     {
00024         LightType mType;
00025         Ogre::Real mPhase;
00026         Ogre::Real mDirection;
00027 
00028         static Ogre::Real pulseAmplitude(Ogre::Real time);
00029 
00030         static Ogre::Real flickerAmplitude(Ogre::Real time);
00031         static Ogre::Real flickerFrequency(Ogre::Real phase);
00032 
00033     public:
00034         // MSVC needs the constructor for a class inheriting a template to be defined in header
00035         LightFunction(LightType type)
00036           : ControllerFunction<Ogre::Real>(true)
00037           , mType(type)
00038           , mPhase(Ogre::Math::RangeRandom(-500.0f, +500.0f))
00039           , mDirection(1.0f)
00040         {
00041         }
00042         virtual Ogre::Real calculate(Ogre::Real value);
00043     };
00044 
00045     class LightValue : public Ogre::ControllerValue<Ogre::Real>
00046     {
00047         Ogre::Light *mTarget;
00048         Ogre::ColourValue mColor;
00049 
00050     public:
00051         // MSVC needs the constructor for a class inheriting a template to be defined in header
00052         LightValue(Ogre::Light *light, const Ogre::ColourValue &color)
00053           : mTarget(light)
00054           , mColor(color)
00055         {
00056         }
00057 
00058         virtual Ogre::Real getValue() const;
00059         virtual void setValue(Ogre::Real value);
00060     };
00061 }
00062 }
00063 
00064 #endif