#include <track_keyframer.h>
Inheritance diagram for NL3D::CTrackKeyFramerConstFloat:
Public Types | |
typedef std::map< TAnimationTime, CKeyFloat > | TMapTimeCKey |
Public Member Functions | |
virtual bool | addBezierFloatKey (const UKeyBezierFloat &key) |
Fail if not A Float Bezier Keyframer. | |
void | addKey (const CKeyFloat &key, TAnimationTime time) |
virtual bool | addLinearFloatKey (const UKeyLinearFloat &key) |
Fail if not A Float Linear Keyframer. | |
virtual bool | addTCBFloatKey (const UKeyTCBFloat &key) |
Fail if not A Float TCB Keyframer. | |
virtual void | eval (const TAnimationTime &inDate) |
From ITrack. | |
virtual void | evalKey (const CKeyFloat *previous, const CKeyFloat *next, TAnimationTime datePrevious, TAnimationTime dateNext, TAnimationTime date) |
From ITrackKeyFramer. | |
virtual TAnimationTime | getBeginTime () const |
virtual std::string | getClassName ()=0 |
virtual TAnimationTime | getEndTime () const |
void | getKeysInRange (TAnimationTime t1, TAnimationTime t2, std::vector< TAnimationTime > &result) |
virtual bool | getLoopMode () const |
get LoopMode. From ITrack | |
TAnimationTime | getRangeDelta () const |
rangeDelta is (length of effective Range) - (length of LastKey-FirstKey). NB: if RangeLock, rangeDelta==0. | |
virtual const IAnimatedValue & | getValue () const |
From ITrack. | |
bool | isRangeLocked () const |
return true if Range is locked to first/last key. use getBeginTime and getEndTime to get the effective begin/end range times... | |
void | lockRange () |
range is computed from frist and last key time (default). | |
NLMISC_DECLARE_CLASS (CTrackKeyFramerConstFloat) | |
virtual void | serial (NLMISC::IStream &f) throw (NLMISC::EStream) |
Serial the template. | |
void | setLoopMode (bool loop) |
set LoopMode. 2 mode only: "constant" (<=>false), and "loop" (<=> true). same mode for in and out... | |
void | unlockRange (TAnimationTime begin, TAnimationTime end) |
set an explicit animation range. (see getBeginTime() / setEndTime() ). | |
Static Public Member Functions | |
UTrackKeyframer * | createBezierFloatTrack () |
UTrackKeyframer * | createLinearFloatTrack () |
UTrackKeyframer * | createTCBFloatTrack () |
Protected Member Functions | |
virtual void | compile () |
float | getCompiledRangeDelta () |
This is for Deriver compile(), because _RangeDelta (getRangeDelta()) is himself computed in compile(). | |
Protected Attributes | |
TMapTimeCKey | _MapKey |
|
Definition at line 65 of file track_keyframer.h. |
|
Fail if not A Float Bezier Keyframer.
Reimplemented in NL3D::CTrackKeyFramerBezierFloat. Definition at line 220 of file u_track.h.
00220 {return false;} |
|
Add a key in the keyframer. The key passed is duplicated in the track.
Definition at line 90 of file track_keyframer.h.
00091 { 00092 // Insert the key in the map 00093 _MapKey.insert (TMapTimeCKey::value_type (time, key)); 00094 00095 // must precalc at next eval. 00096 _Dirty= true; 00097 } |
|
Fail if not A Float Linear Keyframer.
Reimplemented in NL3D::CTrackKeyFramerLinearFloat. Definition at line 218 of file u_track.h.
00218 {return false;} |
|
Fail if not A Float TCB Keyframer.
Reimplemented in NL3D::CTrackKeyFramerTCBFloat. Definition at line 222 of file u_track.h.
00222 {return false;} |
|
Precalc keyframe runtime infos for interpolation (OODTime...). All keys should be processed. This is called by eval when necessary. Deriver should call ITrackKeyFramer::compile() first, to compile basic Key runtime info. Definition at line 302 of file track_keyframer.h.
00303 { 00304 float timeFirstKey; 00305 float timeLastKey; 00306 00307 // Compute time of first/last key. 00308 if( !_MapKey.empty() ) 00309 { 00310 typename TMapTimeCKey::const_iterator ite; 00311 00312 // Get first key 00313 ite=_MapKey.begin (); 00314 timeFirstKey= ite->first; 00315 00316 // Get last key 00317 ite=_MapKey.end (); 00318 ite--; 00319 timeLastKey= ite->first; 00320 } 00321 else 00322 { 00323 timeFirstKey= 0.0f; 00324 timeLastKey= 0.0f; 00325 } 00326 00327 00328 // Compute RangeBegin / RangeEnd. (if not user provided). 00329 if(_RangeLock) 00330 { 00331 _RangeBegin= timeFirstKey; 00332 _RangeEnd= timeLastKey; 00333 } 00334 00335 00336 // Compute _RangeDelta. 00337 if(_RangeLock) 00338 { 00339 _RangeDelta= 0; 00340 } 00341 else 00342 { 00343 _RangeDelta= (_RangeEnd - _RangeBegin) - (timeLastKey - timeFirstKey); 00344 } 00345 00346 // Misc range. 00347 _TotalRange= _RangeEnd - _RangeBegin; 00348 if(_TotalRange>0.0f) 00349 _OOTotalRange= 1.0f/_TotalRange; 00350 // start of loop / ned. 00351 _LoopStart= timeFirstKey; 00352 _LoopEnd= timeFirstKey + _TotalRange; 00353 00354 00355 // After _RangeDelta computed, compute OO delta times. 00356 typename TMapTimeCKey::iterator it= _MapKey.begin(); 00357 for(;it!=_MapKey.end();it++) 00358 { 00359 typename TMapTimeCKey::iterator next= it; 00360 next++; 00361 if(next!=_MapKey.end()) 00362 it->second.OODeltaTime= 1.0f/(next->first - it->first); 00363 else if(_RangeDelta>0.0f) 00364 // after last key, must slerp to first key. 00365 it->second.OODeltaTime= 1.0f/_RangeDelta; 00366 else 00367 it->second.OODeltaTime= 0.0f; 00368 } 00369 00370 } |
|
Definition at line 87 of file track_keyframer.cpp.
00088 { 00089 return new CTrackKeyFramerBezierFloat; 00090 } |
|
Definition at line 83 of file track_keyframer.cpp.
00084 { 00085 return new CTrackKeyFramerLinearFloat; 00086 } |
|
Definition at line 91 of file track_keyframer.cpp.
00092 { 00093 return new CTrackKeyFramerTCBFloat; 00094 } |
|
From ITrack.
Implements NL3D::ITrack. Definition at line 137 of file track_keyframer.h.
00138 { 00139 float date= inDate; 00140 const CKeyT *previous=NULL; 00141 const CKeyT *next=NULL; 00142 TAnimationTime datePrevious = 0; 00143 TAnimationTime dateNext = 0; 00144 00145 // must precalc ?? 00146 testAndClean(); 00147 00148 // No keys? 00149 if(_MapKey.empty()) 00150 return; 00151 00152 00153 // Loop gestion. 00154 if(_LoopMode && _MapKey.size()>1 ) 00155 { 00156 nlassert(_LoopEnd > _LoopStart); 00157 00158 // force us to be in interval [_LoopStart, _LoopEnd[. 00159 if( date<_LoopStart || date>=_LoopEnd ) 00160 { 00161 double d= (date-_LoopStart)*_OOTotalRange; 00162 00163 // floor(d) is the truncated number of loops. 00164 d= date- floor(d)*_TotalRange; 00165 date= (float)d; 00166 00167 // For precision problems, ensure correct range. 00168 if(date<_LoopStart || date >= _LoopEnd) 00169 date= _LoopStart; 00170 } 00171 } 00172 00173 00174 // Return upper key 00175 typename TMapTimeCKey::iterator ite=_MapKey.upper_bound (date); 00176 00177 // First next ? 00178 if (ite!=_MapKey.end()) 00179 { 00180 // Next 00181 next= &(ite->second); 00182 dateNext=ite->first; 00183 } 00184 // loop mgt. 00185 else if (_LoopMode && _MapKey.size()>1 ) 00186 { 00187 // loop to first!! 00188 next= &(_MapKey.begin()->second); 00189 // must slerp from last to first, 00190 dateNext= _LoopEnd; 00191 } 00192 else if (!_LoopMode && _MapKey.size()>=1 ) 00193 { 00194 // clamp to the last 00195 typename TMapTimeCKey::iterator iteLast= ite; 00196 iteLast--; 00197 next= &(iteLast->second); 00198 } 00199 00200 00201 // First previous ? 00202 if ((!_MapKey.empty())&&(ite!=_MapKey.begin())) 00203 { 00204 if (ite!=_MapKey.end()) 00205 { 00206 // Previous 00207 ite--; 00208 previous= &(ite->second); 00209 datePrevious=ite->first; 00210 } 00211 } 00212 else if (!_MapKey.empty()) 00213 { 00214 // Clamp at beginTime 00215 next= &(ite->second); 00216 dateNext=ite->first; 00217 } 00218 00219 // Call evalutation fonction 00220 evalKey (previous, next, datePrevious, dateNext, date); 00221 } |
|
From ITrackKeyFramer.
Implements NL3D::ITrackKeyFramer< CKeyFloat >. Definition at line 482 of file track_keyframer.h.
00485 { 00486 // Const key. 00487 if (previous) 00488 copyToValue(_Value.Value, previous->Value); 00489 else 00490 if (next) 00491 copyToValue(_Value.Value, next->Value); 00492 } |
|
Get the begin time of the track Implements NL3D::UTrack. Definition at line 224 of file track_keyframer.h.
00225 { 00226 // must precalc ?? 00227 testAndClean(); 00228 00229 return _RangeBegin; 00230 } |
|
Implemented in NLAIAGENT::CNumericIndex, NLAIC::IPointerGestion, NLAIC::CIdentType, and CAutomataDesc. Referenced by NLMISC::CClassRegistry::checkObject(), and NL3D::GetTextureSize(). |
|
This is for Deriver compile(), because _RangeDelta (getRangeDelta()) is himself computed in compile().
Definition at line 291 of file track_keyframer.h.
00292 {
00293 return _RangeDelta;
00294 }
|
|
Get the end time of the track Implements NL3D::UTrack. Definition at line 231 of file track_keyframer.h.
00232 { 00233 // must precalc ?? 00234 testAndClean(); 00235 00236 return _RangeEnd; 00237 } |
|
From UTrackKeyframer, retrieve the keys that are in the given range [t1, t2] of the track
Implements NL3D::UTrackKeyframer. |
|
get LoopMode. From ITrack
Implements NL3D::ITrack. Definition at line 133 of file track_keyframer.h.
00133 {return _LoopMode;}
|
|
rangeDelta is (length of effective Range) - (length of LastKey-FirstKey). NB: if RangeLock, rangeDelta==0.
Definition at line 120 of file track_keyframer.h.
00121 { 00122 // update track. 00123 testAndClean(); 00124 00125 return _RangeDelta; 00126 } |
|
From ITrack.
Implements NL3D::ITrack. Definition at line 476 of file track_keyframer.h.
00477 {
00478 return _Value;
00479 }
|
|
Interplation a bool value. You should be sure that the track you use to interpolate your value is a bool track! An assertion will be raised in debug if the type is wrong.
Implements NL3D::UTrack. Definition at line 202 of file track.cpp. References NL3D::CAnimatedValueBool, NL3D::ITrack::eval(), NL3D::ITrack::getValue(), NL3D_HAUTO_UTRACK_INTERPOLATE, res, NL3D::TAnimationTime, and value.
00203 { 00204 NL3D_HAUTO_UTRACK_INTERPOLATE; 00205 00206 // Evaluate it 00207 eval (time); 00208 00209 // Get a pointer on the value 00210 const CAnimatedValueBool *value=dynamic_cast<const CAnimatedValueBool*>(&getValue ()); 00211 00212 // Type is good ? 00213 if (value) 00214 { 00215 // Ok, return the value 00216 res=value->Value; 00217 return true; 00218 } 00219 else 00220 // No, return false 00221 return false; 00222 } |
|
Interplation a string value. You should be sure that the track you use to interpolate your value is a string track! An assertion will be raised in debug if the type is wrong.
Implements NL3D::UTrack. Definition at line 178 of file track.cpp. References NL3D::CAnimatedValueString, NL3D::ITrack::eval(), NL3D::ITrack::getValue(), NL3D_HAUTO_UTRACK_INTERPOLATE, res, NL3D::TAnimationTime, and value.
00179 { 00180 NL3D_HAUTO_UTRACK_INTERPOLATE; 00181 00182 // Evaluate it 00183 eval (time); 00184 00185 // Get a pointer on the value 00186 const CAnimatedValueString *value=dynamic_cast<const CAnimatedValueString*>(&getValue ()); 00187 00188 // Type is good ? 00189 if (value) 00190 { 00191 // Ok, return the value 00192 res=value->Value; 00193 return true; 00194 } 00195 else 00196 // No, return false 00197 return false; 00198 } |
|
Interplation a CQuat value. You should be sure that the track you use to interpolate your value is a CQuat track! An assertion will be raised in debug if the type is wrong.
Implements NL3D::UTrack. Definition at line 154 of file track.cpp. References NL3D::CAnimatedValueQuat, NL3D::ITrack::eval(), NL3D::ITrack::getValue(), NL3D_HAUTO_UTRACK_INTERPOLATE, res, NL3D::TAnimationTime, and value.
00155 { 00156 NL3D_HAUTO_UTRACK_INTERPOLATE; 00157 00158 // Evaluate it 00159 eval (time); 00160 00161 // Get a pointer on the value 00162 const CAnimatedValueQuat *value=dynamic_cast<const CAnimatedValueQuat*>(&getValue ()); 00163 00164 // Type is good ? 00165 if (value) 00166 { 00167 // Ok, return the value 00168 res=value->Value; 00169 return true; 00170 } 00171 else 00172 // No, return false 00173 return false; 00174 } |
|
Interplation a CVector value. You should be sure that the track you use to interpolate your value is a CVector track! An assertion will be raised in debug if the type is wrong.
Implements NL3D::UTrack. Definition at line 130 of file track.cpp. References NL3D::CAnimatedValueVector, NL3D::ITrack::eval(), NL3D::ITrack::getValue(), NL3D_HAUTO_UTRACK_INTERPOLATE, res, NL3D::TAnimationTime, and value.
00131 { 00132 NL3D_HAUTO_UTRACK_INTERPOLATE; 00133 00134 // Evaluate it 00135 eval (time); 00136 00137 // Get a pointer on the value 00138 const CAnimatedValueVector *value=dynamic_cast<const CAnimatedValueVector*>(&getValue ()); 00139 00140 // Type is good ? 00141 if (value) 00142 { 00143 // Ok, return the value 00144 res=value->Value; 00145 return true; 00146 } 00147 else 00148 // No, return false 00149 return false; 00150 } |
|
Interplation a CRGBA value. You should be sure that the track you use to interpolate your value is an CRGBA track! An assertion will be raised in debug if the type is wrong.
Implements NL3D::UTrack. Definition at line 106 of file track.cpp. References NL3D::CAnimatedValueRGBA, NL3D::ITrack::eval(), NL3D::ITrack::getValue(), NL3D_HAUTO_UTRACK_INTERPOLATE, res, NL3D::TAnimationTime, and value.
00107 { 00108 NL3D_HAUTO_UTRACK_INTERPOLATE; 00109 00110 // Evaluate it 00111 eval (time); 00112 00113 // Get a pointer on the value 00114 const CAnimatedValueRGBA *value=dynamic_cast<const CAnimatedValueRGBA*>(&getValue ()); 00115 00116 // Type is good ? 00117 if (value) 00118 { 00119 // Ok, return the value 00120 res=value->Value; 00121 return true; 00122 } 00123 else 00124 // No, return false 00125 return false; 00126 } |
|
Interplation an integer value. You should be sure that the track you use to interpolate your value is an integer track! An assertion will be raised in debug if the type is wrong.
Implements NL3D::UTrack. Definition at line 82 of file track.cpp. References NL3D::CAnimatedValueInt, NL3D::ITrack::eval(), NL3D::ITrack::getValue(), NL3D_HAUTO_UTRACK_INTERPOLATE, res, sint32, NL3D::TAnimationTime, and value.
00083 { 00084 NL3D_HAUTO_UTRACK_INTERPOLATE; 00085 00086 // Evaluate it 00087 eval (time); 00088 00089 // Get a pointer on the value 00090 const CAnimatedValueInt *value=dynamic_cast<const CAnimatedValueInt*>(&getValue ()); 00091 00092 // Type is good ? 00093 if (value) 00094 { 00095 // Ok, return the value 00096 res=value->Value; 00097 return true; 00098 } 00099 else 00100 // No, return false 00101 return false; 00102 } |
|
Interplation a float value. You should be sure that the track you use to interpolate your value is a float track! An assertion will be raised in debug if the type is wrong.
Implements NL3D::UTrack. |
|
return true if Range is locked to first/last key. use getBeginTime and getEndTime to get the effective begin/end range times...
Definition at line 116 of file track_keyframer.h.
00116 {return _RangeLock;}
|
|
range is computed from frist and last key time (default).
Definition at line 109 of file track_keyframer.h.
00110 { 00111 _RangeLock= true; 00112 _Dirty= true; 00113 } |
|
|
|
Serial the template.
Implements NLMISC::IStreamable. Definition at line 241 of file track_keyframer.h.
00242 { 00243 // Serial version 00244 (void)f.serialVersion (0); 00245 00246 f.serialCont(_MapKey); 00247 f.serial(_RangeLock, _RangeBegin, _RangeEnd); 00248 f.serial(_LoopMode); 00249 00250 if(f.isReading()) 00251 _Dirty= true; 00252 } |
|
set LoopMode. 2 mode only: "constant" (<=>false), and "loop" (<=> true). same mode for in and out...
Definition at line 130 of file track_keyframer.h.
00130 {_LoopMode= loop; _Dirty= true;}
|
|
set an explicit animation range. (see getBeginTime() / setEndTime() ).
Definition at line 100 of file track_keyframer.h.
00101 { 00102 _RangeLock= false; 00103 _RangeBegin= begin; 00104 _RangeEnd= end; 00105 _Dirty= true; 00106 } |
|
Definition at line 287 of file track_keyframer.h. |