BaseFCurve.h

Go to the documentation of this file.
00001 //***************************************************************************************
00002 // File supervisor: Crosswalk team
00012 //***************************************************************************************
00013 
00014 #ifndef _BASEFCURVE_H
00015 #define _BASEFCURVE_H
00016 
00017 #include "Template.h"
00018 
00019 extern CEnumDictionary<CSLTemplate::EFCurveInterpolationType, CSLTemplate::SI_CUBIC> g_FCurveInterpolationTypeDictionary;
00020 
00026 struct CSLBaseKey
00027 {
00028     SI_Float m_fTime;   
00029     SI_Float m_fValue;  
00030 };
00031 
00034 struct CSLConstantKey : public CSLBaseKey
00035 {
00036 };
00037 
00038 
00041 struct CSLLinearKey : public CSLBaseKey
00042 {
00043 };
00044 
00045 
00048 struct CSLHermiteKey : public CSLBaseKey
00049 {
00050     SI_Float m_fInTangent;
00051     SI_Float m_fOutTangent;
00052 };
00053 
00056 struct CSLBezierKey : public CSLBaseKey
00057 {
00058     SI_Float m_fInTangentX;
00059     SI_Float m_fInTangentY;
00060     SI_Float m_fOutTangentX;
00061     SI_Float m_fOutTangentY;
00062 };
00063 
00066 struct CSLCubicKey : public CSLBaseKey
00067 {
00068     SI_Float m_fLeftTanX;
00069     SI_Float m_fLeftTanY;
00070     SI_Float m_fRightTanX;
00071     SI_Float m_fRightTanY;
00072 };
00073 
00087 class XSIEXPORT CSLBaseFCurve
00088     : public CSLTemplate
00089 {
00090 public:
00093     typedef CSLArrayProxy<CSLConstantKey, SI_Float, 2> CSLConstantKeyArray;
00094 
00097     typedef CSLArrayProxy<CSLLinearKey, SI_Float, 2> CSLLinearKeyArray;
00098 
00101     typedef CSLArrayProxy<CSLHermiteKey, SI_Float, 4> CSLHermiteKeyArray;
00102 
00105     typedef CSLArrayProxy<CSLBezierKey, SI_Float, 6> CSLBezierKeyArray;
00106 
00109     typedef CSLArrayProxy<CSLCubicKey, SI_Float, 6> CSLCubicKeyArray;
00110 
00112     virtual ~CSLBaseFCurve();
00113 
00119     CSLConstantKeyArray* GetConstantKeyList();
00120 
00126     CSLCubicKeyArray* GetCubicKeyList();
00127 
00133     CSLHermiteKeyArray* GetHermiteKeyList();
00134 
00140     CSLBezierKeyArray* GetBezierKeyList();
00141 
00147     CSLLinearKeyArray* GetLinearKeyList();
00148 
00154     CSLConstantKey* GetConstantKeyListPtr();
00155 
00161     CSLCubicKey* GetCubicKeyListPtr();
00162 
00168     CSLHermiteKey* GetHermiteKeyListPtr();
00169 
00175     CSLBezierKey* GetBezierKeyListPtr();
00176 
00182     CSLLinearKey* GetLinearKeyListPtr();
00183 
00189     CSLTemplate::EFCurveInterpolationType GetInterpolationType();
00190 
00194     SI_Int GetKeyValueCount();
00195 
00200     SI_Int GetKeyCount();
00201 
00207     SI_Error Evaluate( SI_Float in_fTime );
00208 
00213     SI_Float GetLastEvaluation() { return m_fLastEvaluation; };
00214 
00219     SI_Float GetValueAtNextFrame ( SI_Float in_fFloat );
00220 
00225     SI_Float GetValueAtPrevFrame ( SI_Float in_fFloat );
00226 
00232     SI_Int  FindKeyAtOrBefore ( SI_Float in_fFloat );
00233 
00237     CSLAnimatableType* GetParameter();
00238 
00244     CSLAnimatableType* ConnectParameter(CSLAnimatableType* in_pNewParameter);
00245 
00246     virtual SI_Error Synchronize();
00247 
00248 protected:
00249 
00256     CSLBaseFCurve
00257     (
00258         CSLScene* in_pScene,
00259         CSLModel *in_pModel,
00260         CdotXSITemplate* in_pTemplate,
00261         EFCurveInterpolationType in_InterpolationType
00262     );
00263     CSLAnimatableType* m_pParameter;
00264 
00265 private:
00266     CSLStrEnumProxy<EFCurveInterpolationType, SI_CUBIC> m_InterpolationType;
00267     union
00268     {
00269         CSLConstantKeyArray* m_pConstantKeys;
00270         CSLLinearKeyArray* m_pLinearKeys;
00271         CSLHermiteKeyArray* m_pHermiteKeys;
00272         CSLBezierKeyArray* m_pBezierKeys;
00273         CSLCubicKeyArray* m_pCubicKeys;
00274     };
00275 
00276     SI_Int              m_iCurrentKey;      // for evaluation optimization
00277     SI_Float            m_fCurrentTime;     // @DEBUG
00278     SI_Float            m_fLastEvaluation;  // Hold the value of the last evaluation
00279 
00280     inline SI_Float GetTimeAtKey ( SI_Int );
00281 
00282     void *m_pReserved;  // reserved for future extension
00283 };
00284 
00285 #endif