Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

fader_texture.H

Go to the documentation of this file.
00001 /**********************************************************************
00002  * fader_texture.H:
00003  **********************************************************************/
00004 #ifndef FADER_TEXTURE_H_IS_INCLUDED
00005 #define FADER_TEXTURE_H_IS_INCLUDED
00006 
00007 #include "mesh/gtexture.H"
00008 
00009 /**********************************************************************
00010  * FaderTexture:
00011  *
00012  *      Fades from one texture to another over a given time interval.
00013  **********************************************************************/
00014 class FaderTexture : public GTexture {
00015  public:
00016    //******** MANAGERS ********
00017    FaderTexture(GTexture* base, GTexture* fader, double start, double dur) :
00018       GTexture(base->patch()),
00019       _base(base),
00020       _fader(fader),
00021       _start_time(start),
00022       _duration(dur) {
00023       _base->set_ctrl(this);      // take control of the base
00024    }
00025 
00026    virtual ~FaderTexture() {}
00027 
00028    //******** RUN-TIME TYPE ID ********
00029    DEFINE_RTTI_METHODS2("FaderTexture", GTexture, CDATA_ITEM*);
00030 
00031    //******** GTexture VIRTUAL METHODS ********
00032    virtual int draw(CVIEWptr& v);
00033 
00034    //******** DATA_ITEM VIRTUAL METHODS ********
00035    virtual DATA_ITEM  *dup() const { return 0; }
00036 
00037  protected:
00038    GTexture*    _base;          // texture that is fading in
00039    GTexture*    _fader;         // texture that is fading away
00040    double       _start_time;    // frame time at start of fade
00041    double       _duration;      // fade duration (in frame time)
00042 
00043    // convenience: convert time to opacity (alpha)
00044    double fade(double t) const {
00045       return 1.0 - clamp((t - _start_time)/_duration, 0.0, 1.0);
00046    }
00047 };
00048 
00049 #endif // FADER_TEXTURE_H_IS_INCLUDED
00050 
00051 /* end of file fader_texture.H */

Generated on Mon Sep 18 11:39:29 2006 for jot by  doxygen 1.4.4