OpenMW
libs/openengine/ogre/fader.hpp
Go to the documentation of this file.
00001 #ifndef OENGINE_OGRE_FADE_H
00002 #define OENGINE_OGRE_FADE_H
00003 
00004 /*
00005   A class that handles fading in the screen from black or fading it out to black.
00006   
00007   To achieve this, it uses a full-screen Rectangle2d
00008  */
00009  
00010 namespace Ogre
00011 {
00012     class TextureUnitState;
00013     class Rectangle2D;
00014     class SceneManager;
00015 }
00016 
00017 namespace OEngine {
00018 namespace Render
00019 {
00020     class Fader
00021     {
00022     public:
00023         Fader(Ogre::SceneManager* sceneMgr);
00024         ~Fader();
00025 
00026         void update(float dt);
00027 
00028         void fadeIn(const float time);
00029         void fadeOut(const float time);
00030         void fadeTo(const int percent, const float time);
00031 
00032         void setFactor (float factor) { mFactor = factor; }
00033 
00034     private:
00035         enum FadingMode
00036         {
00037             FadingMode_In,
00038             FadingMode_Out
00039         };
00040 
00041         void applyAlpha();
00042 
00043         Ogre::TextureUnitState* mFadeTextureUnit;
00044         Ogre::Rectangle2D* mRectangle;
00045 
00046         FadingMode mMode;
00047 
00048         float mRemainingTime;
00049         float mTargetTime;
00050         float mTargetAlpha;
00051         float mCurrentAlpha;
00052         float mStartAlpha;
00053 
00054         float mFactor;
00055 
00056         Ogre::SceneManager* mSceneMgr;
00057     };
00058     }}
00059 #endif