00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_TRACK_H
00027 #define NL_TRACK_H
00028
00029 #include "nel/misc/stream.h"
00030 #include "nel/misc/types_nl.h"
00031 #include "nel/misc/common.h"
00032
00033 #include "nel/3d/animation_time.h"
00034 #include "nel/3d/u_track.h"
00035
00036 #include "3d/animated_value.h"
00037
00038
00039 namespace NL3D
00040 {
00041
00042
00043 using NLMISC::CQuat;
00044 using NLMISC::CVector;
00045
00046
00047
00058 class ITrack : public NLMISC::IStreamable, public UTrack
00059 {
00060 public:
00064 virtual ~ITrack() {};
00065
00072 virtual void eval (const TAnimationTime& date)=0;
00073
00079 virtual const IAnimatedValue& getValue () const=0;
00080
00085 virtual bool getLoopMode() const=0;
00086
00088
00089
00090 virtual bool interpolate (TAnimationTime time, float& res);
00091 virtual bool interpolate (TAnimationTime time, sint32& res);
00092 virtual bool interpolate (TAnimationTime time, NLMISC::CRGBA& res);
00093 virtual bool interpolate (TAnimationTime time, NLMISC::CVector& res);
00094 virtual bool interpolate (TAnimationTime time, NLMISC::CQuat& res);
00095 virtual bool interpolate (TAnimationTime time, std::string& res);
00096 virtual bool interpolate (TAnimationTime time, bool& res);
00097
00098
00099 };
00100
00101
00102
00112 class ITrackDefault : public ITrack
00113 {
00114 public:
00116 virtual void eval (const TAnimationTime& date)
00117 {}
00118 TAnimationTime getBeginTime () const
00119 {
00120 return 0.f;
00121 }
00122 TAnimationTime getEndTime () const
00123 {
00124 return 0.f;
00125 }
00126 virtual bool getLoopMode() const {return true;}
00127 };
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00148 template<class T>
00149 class CTrackDefaultBlendable : public ITrackDefault
00150 {
00151 public:
00152
00153 CTrackDefaultBlendable()
00154 {
00155 }
00156 CTrackDefaultBlendable(const T &val)
00157 {
00158 _Value.Value= val;
00159 }
00160
00162 void setValue(const T &val)
00163 {
00164 _Value.Value= val;
00165 }
00166
00167
00169 virtual const IAnimatedValue& getValue () const
00170 {
00171 return _Value;
00172 }
00173
00175 virtual void serial (NLMISC::IStream& f) throw (NLMISC::EStream)
00176 {
00177
00178 (void)f.serialVersion (0);
00179
00180
00181 f.serial (_Value.Value);
00182 }
00183 private:
00184
00185
00186 CAnimatedValueBlendable<T> _Value;
00187 };
00188
00189
00199 template<class T>
00200 class CTrackDefaultNotBlendable : public ITrackDefault
00201 {
00202 public:
00203
00204 CTrackDefaultNotBlendable()
00205 {
00206 }
00207 CTrackDefaultNotBlendable(const T &val)
00208 {
00209 _Value.Value= val;
00210 }
00211
00213 void setValue(const T &val)
00214 {
00215 _Value.Value= val;
00216 }
00217
00218
00220 virtual const IAnimatedValue& getValue () const
00221 {
00222 return _Value;
00223 }
00224
00226 virtual void serial (NLMISC::IStream& f) throw (NLMISC::EStream)
00227 {
00228
00229 (void)f.serialVersion (0);
00230
00231
00232 f.serial (_Value.Value);
00233 }
00234 private:
00235
00236
00237 CAnimatedValueNotBlendable<T> _Value;
00238 };
00239
00240
00241 #define NL3D_TRACKDEF_CTOR(_Son, _Father, _T) \
00242 _Son() {} \
00243 _Son(const _T &v) : _Father<_T>(v) {}
00244
00245
00246
00247 class CTrackDefaultFloat : public CTrackDefaultBlendable<float>
00248 {
00249 public:
00250 NL3D_TRACKDEF_CTOR(CTrackDefaultFloat, CTrackDefaultBlendable, float);
00251 NLMISC_DECLARE_CLASS (CTrackDefaultFloat);
00252 };
00253 class CTrackDefaultVector : public CTrackDefaultBlendable<CVector>
00254 {
00255 public:
00256 NL3D_TRACKDEF_CTOR(CTrackDefaultVector, CTrackDefaultBlendable, CVector);
00257 NLMISC_DECLARE_CLASS (CTrackDefaultVector);
00258 };
00259 class CTrackDefaultQuat : public CTrackDefaultBlendable<CQuat>
00260 {
00261 public:
00262 NL3D_TRACKDEF_CTOR(CTrackDefaultQuat, CTrackDefaultBlendable, CQuat);
00263 NLMISC_DECLARE_CLASS (CTrackDefaultQuat);
00264 };
00265 class CTrackDefaultInt : public CTrackDefaultBlendable<sint32>
00266 {
00267 public:
00268 NL3D_TRACKDEF_CTOR(CTrackDefaultInt, CTrackDefaultBlendable, sint32);
00269 NLMISC_DECLARE_CLASS (CTrackDefaultInt);
00270 };
00271
00272 class CTrackDefaultRGBA : public CTrackDefaultBlendable<NLMISC::CRGBA>
00273 {
00274 public:
00275 NL3D_TRACKDEF_CTOR(CTrackDefaultRGBA, CTrackDefaultBlendable, NLMISC::CRGBA);
00276 NLMISC_DECLARE_CLASS (CTrackDefaultRGBA);
00277 };
00278
00279
00280 class CTrackDefaultString : public CTrackDefaultNotBlendable<std::string>
00281 {
00282 public:
00283 NL3D_TRACKDEF_CTOR(CTrackDefaultString, CTrackDefaultNotBlendable, std::string);
00284 NLMISC_DECLARE_CLASS (CTrackDefaultString);
00285 };
00286 class CTrackDefaultBool : public CTrackDefaultNotBlendable<bool>
00287 {
00288 public:
00289 NL3D_TRACKDEF_CTOR(CTrackDefaultBool, CTrackDefaultNotBlendable, bool);
00290 NLMISC_DECLARE_CLASS (CTrackDefaultBool);
00291 };
00292
00293 }
00294
00295
00296 #endif // NL_TRACK_H
00297
00298