CTCBTools< CKeyT, T, TMapTimeCKey > Class Template Reference

#include <track_tcb.h>

Inheritance diagram for CTCBTools< CKeyT, T, TMapTimeCKey >:

CTrackKeyFramerTCB< CKeyT, T > CTrackKeyFramerTCB< CKeyTCBQuat, NLMISC::CAngleAxis >

Detailed Description

template<class CKeyT, class T, class TMapTimeCKey>
class CTCBTools< CKeyT, T, TMapTimeCKey >

TCB Track tools (for both normal TCB, and quat TCB). internal use.

Author:
Cyril 'Hulud' Corvazier

Nevrax France

Date:
2001

Definition at line 48 of file track_tcb.h.

Protected Types

typedef TMapTimeCKey::iterator TMapTimeCKeyIterator

Protected Member Functions

void compileTCBEase (TMapTimeCKey &mapKey, bool loopMode)
 compute TCB ease information.

void computeHermiteBasis (float d, float hb[4])
void computeTCBFactors (const CKeyT &key, float timeBefore, float time, float timeAfter, float rangeDelta, bool firstKey, bool endKey, bool isLoop, float &ksm, float &ksp, float &kdm, float &kdp)
float ease (const CKeyT *key, float d)


Member Typedef Documentation

template<class CKeyT, class T, class TMapTimeCKey>
typedef TMapTimeCKey::iterator CTCBTools< CKeyT, T, TMapTimeCKey >::TMapTimeCKeyIterator [protected]
 

Definition at line 51 of file track_tcb.h.


Member Function Documentation

template<class CKeyT, class T, class TMapTimeCKey>
void CTCBTools< CKeyT, T, TMapTimeCKey >::compileTCBEase TMapTimeCKey &  mapKey,
bool  loopMode
[inline, protected]
 

compute TCB ease information.

Definition at line 56 of file track_tcb.h.

Referenced by CTrackKeyFramerTCB< CKeyTCBQuat, NLMISC::CAngleAxis >::compile(), and CTrackKeyFramerTCB< CKeyT, T >::compile().

00057         {
00058                 TMapTimeCKeyIterator    it= mapKey.begin();
00059                 for(;it!=mapKey.end();it++)
00060                 {
00061                         TMapTimeCKeyIterator    next= it;
00062                         next++;
00063 
00064                         // loop mgt. must compute ease from last to first (usefull if _RangeLock is false).
00065                         if(next==mapKey.end() && loopMode && mapKey.size()>1)
00066                                 next= mapKey.begin();
00067 
00068                         // Ease Precompute.
00069                         //=================
00070                         CKeyT   &key= it->second;
00071                         if(next!=mapKey.end())
00072                         {
00073                                 float   e0= it->second.EaseFrom;
00074                                 float   e1= next->second.EaseTo;
00075                                 float   s =  e0 + e1;
00076                                 
00077                                 // "normalize".
00078                                 if (s > 1.0f)
00079                                 {
00080                                         e0 = e0/s;
00081                                         e1 = e1/s;
00082                                 }
00083 
00084                                 // precalc ease factors.
00085                                 key.Ease0= e0;
00086                                 key.Ease1= e1;
00087                                 key.EaseK= 1/(2.0f - e0 - e1);
00088                                 if(e0)
00089                                         key.EaseKOverEase0= key.EaseK / e0;
00090                                 if(e1)
00091                                         key.EaseKOverEase1= key.EaseK / e1;
00092                         }
00093                         else
00094                         {
00095                                 // force ease() to just return d (see ease()).
00096                                 key.EaseK = 0.5f;
00097                         }
00098 
00099                 }
00100         }

template<class CKeyT, class T, class TMapTimeCKey>
void CTCBTools< CKeyT, T, TMapTimeCKey >::computeHermiteBasis float  d,
float  hb[4]
[inline, protected]
 

Definition at line 121 of file track_tcb.h.

Referenced by CTrackKeyFramerTCB< CKeyT, T >::evalKey().

00122         {
00123                 float d2,d3,a;
00124                 
00125                 d2 = d*d;
00126                 d3 = d2*d;
00127                 a  = 3.0f*d2 - 2.0f*d3;
00128                 hb[0] = 1.0f - a;
00129                 hb[1] = a;
00130                 hb[2] = d3 - 2.0f*d2 + d;
00131                 hb[3] = d3 - d2;
00132         }

template<class CKeyT, class T, class TMapTimeCKey>
void CTCBTools< CKeyT, T, TMapTimeCKey >::computeTCBFactors const CKeyT &  key,
float  timeBefore,
float  time,
float  timeAfter,
float  rangeDelta,
bool  firstKey,
bool  endKey,
bool  isLoop,
float &  ksm,
float &  ksp,
float &  kdm,
float &  kdp
[inline, protected]
 

Definition at line 136 of file track_tcb.h.

Referenced by CTrackKeyFramerTCB< CKeyTCBQuat, NLMISC::CAngleAxis >::computeTCBKey(), and CTrackKeyFramerTCB< CKeyT, T >::computeTCBKey().

00138         {
00139                 float fp,fn;
00140 
00141                 if(isLoop || (!firstKey && !endKey))
00142                 {
00143                         float   dtm;
00144                         // Compute Time deltas.
00145                         if (firstKey)
00146                         {
00147                                 dtm = 0.5f * (rangeDelta + timeAfter - time);
00148                                 fp = rangeDelta / dtm;
00149                                 fn = (timeAfter - time) / dtm;
00150                         }
00151                         else if (endKey)
00152                         {
00153                                 dtm = 0.5f * (rangeDelta + time - timeBefore);
00154                                 fp = rangeDelta / dtm;
00155                                 fn = (time - timeBefore) / dtm;
00156                         }
00157                         else
00158                         {
00159                                 dtm = 0.5f * (timeAfter - timeBefore);
00160                                 fp = (time - timeBefore) / dtm;
00161                                 fn = (timeAfter - time) / dtm;
00162                         }
00163                         float   c= (float)fabs( key.Continuity );
00164                         fp = fp + c - c * fp;
00165                         fn = fn + c - c * fn;
00166                 }
00167                 else
00168                 {
00169                         // firstkey and lastkey of not loop track.
00170                         fp = 1.0f;
00171                         fn = 1.0f;
00172                 }
00173 
00174                 // Compute tangents factors.
00175                 float   tm,cm,cp,bm,bp,tmcm,tmcp;
00176 
00177                 cm = 1.0f - key.Continuity;
00178                 tm = 0.5f * ( 1.0f - key.Tension );
00179                 cp = 2.0f - cm;
00180                 bm = 1.0f - key.Bias;
00181                 bp = 2.0f - bm;
00182                 tmcm = tm*cm;   tmcp = tm*cp;
00183 
00184                 // tgts factors.
00185                 ksm = tmcm*bp*fp;       ksp = tmcp*bm*fp;
00186                 kdm = tmcp*bp*fn;       kdp = tmcm*bm*fn;
00187 
00188         }

template<class CKeyT, class T, class TMapTimeCKey>
float CTCBTools< CKeyT, T, TMapTimeCKey >::ease const CKeyT *  key,
float  d
[inline, protected]
 

Definition at line 103 of file track_tcb.h.

Referenced by CTrackKeyFramerTCB< CKeyTCBQuat, NLMISC::CAngleAxis >::evalKey(), and CTrackKeyFramerTCB< CKeyT, T >::evalKey().

00104         {
00105                 if (d==0.0f || d==1.0f) return d;
00106                 // k==0.5f <=> e0+e1 == 0.
00107                 if (key->EaseK == 0.5f) return d;
00108 
00109                 if (d < key->Ease0)
00110                         return key->EaseKOverEase0 * d*d;
00111                 else if (d < 1.0f - key->Ease1)
00112                         return key->EaseK * (2.0f*d - key->Ease0);
00113                 else
00114                 {
00115                         d = 1.0f - d;
00116                         return 1.0f - key->EaseKOverEase1 * d*d;
00117                 }
00118         }


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 06:43:53 2004 for NeL by doxygen 1.3.6