00001
00002
00003
00004 #ifndef FADER_TEXTURE_H_IS_INCLUDED
00005 #define FADER_TEXTURE_H_IS_INCLUDED
00006
00007 #include "mesh/gtexture.H"
00008
00009
00010
00011
00012
00013
00014 class FaderTexture : public GTexture {
00015 public:
00016
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);
00024 }
00025
00026 virtual ~FaderTexture() {}
00027
00028
00029 DEFINE_RTTI_METHODS2("FaderTexture", GTexture, CDATA_ITEM*);
00030
00031
00032 virtual int draw(CVIEWptr& v);
00033
00034
00035 virtual DATA_ITEM *dup() const { return 0; }
00036
00037 protected:
00038 GTexture* _base;
00039 GTexture* _fader;
00040 double _start_time;
00041 double _duration;
00042
00043
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