fbxanimcurve.h

Go to the documentation of this file.
00001 /****************************************************************************************
00002  
00003    Copyright (C) 2012 Autodesk, Inc.
00004    All rights reserved.
00005  
00006    Use of this software is subject to the terms of the Autodesk license agreement
00007    provided at the time of installation or download, or which otherwise accompanies
00008    this software in either electronic or hard copy form.
00009  
00010 ****************************************************************************************/
00011 
00013 #ifndef _FBXSDK_SCENE_ANIMATION_CURVE_H_
00014 #define _FBXSDK_SCENE_ANIMATION_CURVE_H_
00015 
00016 #include <fbxsdk/fbxsdk_def.h>
00017 
00018 #include <fbxsdk/core/fbxobject.h>
00019 #include <fbxsdk/scene/animation/fbxanimcurvebase.h>
00020 
00021 #include <fbxsdk/fbxsdk_nsbegin.h>
00022 
00023 class KFCurve;
00024 
00027 class FBXSDK_DLL FbxAnimCurveDef
00028 {
00029 public:
00030     static const float sDEFAULT_WEIGHT;
00031     static const float sMIN_WEIGHT;
00032     static const float sMAX_WEIGHT;
00033     static const float sDEFAULT_VELOCITY;
00034 
00036     enum ETangentMode
00037     {
00038         eTangentAuto = 0x00000100,                                                  
00039         eTangentTCB = 0x00000200,                                                   
00040         eTangentUser = 0x00000400,                                                  
00041         eTangentGenericBreak = 0x00000800,                                          
00042         eTangentBreak = eTangentGenericBreak|eTangentUser,                          
00043         eTangentAutoBreak = eTangentGenericBreak|eTangentAuto,                      
00044         eTangentGenericClamp = 0x00001000,                                          
00045         eTangentGenericTimeIndependent = 0x00002000,                                
00046         eTangentGenericClampProgressive = 0x00004000|eTangentGenericTimeIndependent 
00047     };
00048 
00050     enum EInterpolationType
00051     {
00052         eInterpolationConstant = 0x00000002,    
00053         eInterpolationLinear = 0x00000004,      
00054         eInterpolationCubic = 0x00000008        
00055     };
00056 
00058     enum EWeightedMode
00059     {
00060         eWeightedNone = 0x00000000,                     
00061         eWeightedRight = 0x01000000,                    
00062         eWeightedNextLeft = 0x02000000,                 
00063         eWeightedAll = eWeightedRight|eWeightedNextLeft 
00064     };
00065 
00067     enum EConstantMode
00068     {
00069         eConstantStandard = 0x00000000, 
00070         eConstantNext = 0x00000100      
00071     };
00072 
00074     enum EVelocityMode
00075     {
00076         eVelocityNone = 0x00000000,                     
00077         eVelocityRight = 0x10000000,                    
00078         eVelocityNextLeft = 0x20000000,                 
00079         eVelocityAll = eVelocityRight|eVelocityNextLeft 
00080     };
00081 
00083     enum ETangentVisibility
00084     {
00085         eTangentShowNone = 0x00000000,                          
00086         eTangentShowLeft = 0x00100000,                          
00087         eTangentShowRight = 0x00200000,                         
00088         eTangentShowBoth = eTangentShowLeft|eTangentShowRight   
00089     };
00090 
00092     enum EDataIndex
00093     {
00094         eRightSlope = 0,        
00095         eNextLeftSlope = 1,     
00096         eWeights = 2,           
00097         eRightWeight = 2,       
00098         eNextLeftWeight = 3,    
00099         eVelocity = 4,          
00100         eRightVelocity = 4,     
00101         eNextLeftVelocity = 5,  
00102         eTCBTension = 0,        
00103         eTCBContinuity = 1,     
00104         eTCBBias = 2            
00105     };
00106 };
00107 
00108 struct FBXSDK_DLL FbxAnimCurveTangentInfo
00109 {
00110     inline FbxAnimCurveTangentInfo()
00111     {
00112         mDerivative = 0;
00113         mWeight = FbxAnimCurveDef::sDEFAULT_WEIGHT;
00114         mWeighted = false;
00115         mVelocity = FbxAnimCurveDef::sDEFAULT_VELOCITY;
00116         mHasVelocity = false;
00117         mAuto = 0;
00118     }
00119 
00120     float   mDerivative;
00121     float   mWeight;
00122     float   mVelocity;
00123     float   mAuto;
00124     bool    mWeighted;
00125     bool    mHasVelocity;
00126 };
00127 
00138 class FBXSDK_DLL FbxAnimCurveKey_Impl
00139 {
00140 public:
00143     virtual ~FbxAnimCurveKey_Impl() {};
00144 
00147     virtual FbxAnimCurveKey_Impl& operator=(const FbxAnimCurveKey_Impl& pFKey) = 0;
00148 
00153     virtual void Set(FbxTime pTime, float pValue) = 0;
00154 
00166     virtual void SetTCB(FbxTime pTime, float pValue, float pData0 = 0.0f, float pData1 = 0.0f, float pData2 = 0.0f) = 0;
00167 
00171     virtual float GetValue() const = 0;
00172 
00176     virtual void SetValue(float pValue) = 0;
00177 
00181     virtual FbxAnimCurveDef::EInterpolationType GetInterpolation() const = 0;
00182 
00186     virtual void SetInterpolation (FbxAnimCurveDef::EInterpolationType pInterpolation) = 0;
00187 
00194     virtual FbxAnimCurveDef::ETangentMode GetTangentMode(bool pIncludeOverrides = false) const = 0;
00195 
00199     virtual void SetTangentMode (FbxAnimCurveDef::ETangentMode pTangentMode) = 0;
00200 
00205     virtual FbxAnimCurveDef::EWeightedMode GetTangentWeightMode() const = 0;
00206 
00240     virtual void SetTangentWeightMode(FbxAnimCurveDef::EWeightedMode pTangentWeightMode, FbxAnimCurveDef::EWeightedMode pMask = FbxAnimCurveDef::eWeightedAll ) = 0;
00241 
00246     virtual FbxAnimCurveDef::EVelocityMode GetTangentVelocityMode() const = 0;
00247 
00257     virtual void SetTangentVelocityMode(FbxAnimCurveDef::EVelocityMode pTangentVelocityMode, FbxAnimCurveDef::EVelocityMode pMask = FbxAnimCurveDef::eVelocityAll ) = 0;
00258 
00264     virtual FbxAnimCurveDef::EConstantMode GetConstantMode() const = 0;
00265 
00270     virtual void SetConstantMode(FbxAnimCurveDef::EConstantMode pMode) = 0;
00271 
00290     virtual float GetDataFloat(FbxAnimCurveDef::EDataIndex pIndex) const = 0;
00291 
00307     virtual void SetDataFloat(FbxAnimCurveDef::EDataIndex pIndex, float pValue) = 0;
00308 
00313     virtual void    SetTangentVisibility (FbxAnimCurveDef::ETangentVisibility pVisibility) = 0; 
00314 
00319     virtual FbxAnimCurveDef::ETangentVisibility GetTangentVisibility () const = 0;
00320 
00327     virtual void SetBreak(bool pVal) = 0; 
00328 
00335     virtual bool GetBreak() const = 0; 
00336 };
00337 
00351 class FBXSDK_DLL FbxAnimCurveKey : public FbxAnimCurveKeyBase
00352 {
00353 public:
00356     FbxAnimCurveKey() : FbxAnimCurveKeyBase()
00357     {
00358         FBX_ASSERT(mAllocatorFct != NULL);
00359         mImpl = (*mAllocatorFct)();
00360     }
00361 
00365     FbxAnimCurveKey(FbxTime pTime) : FbxAnimCurveKeyBase()
00366     {
00367         FBX_ASSERT(mAllocatorFct != NULL);
00368         mImpl = (*mAllocatorFct)();
00369         SetTime(pTime);
00370     }
00371 
00376     FbxAnimCurveKey(FbxTime pTime, float pVal) : FbxAnimCurveKeyBase()
00377     {
00378         FBX_ASSERT(mAllocatorFct != NULL);
00379         mImpl = (*mAllocatorFct)();
00380         Set(pTime, pVal);
00381     }
00382 
00385     FbxAnimCurveKey(FbxAnimCurveKey const& pFKey) : FbxAnimCurveKeyBase()
00386     {
00387         FBX_ASSERT(mCopyAllocatorFct != NULL);
00388         SetTime(pFKey.GetTime());
00389         mImpl = mCopyAllocatorFct(pFKey.GetImpl());
00390     }
00391 
00394     ~FbxAnimCurveKey()
00395     {
00396         FBX_ASSERT(mDeallocatorFct != NULL);
00397         (*mDeallocatorFct)(mImpl);
00398     }
00399 
00402     FbxAnimCurveKey& operator=(const FbxAnimCurveKey& pFKey)
00403     {
00404         FBX_ASSERT(mImpl);
00405         if (mImpl)
00406         {
00407             *mImpl = *(pFKey.GetImpl());
00408         }
00409         SetTime(pFKey.GetTime());
00410         return *this;
00411     }
00412 
00416     FbxTime GetTime() const
00417     {
00418         return FbxAnimCurveKeyBase::GetTime();
00419     }
00420 
00424     void SetTime(const FbxTime& pTime)
00425     {
00426         FbxAnimCurveKeyBase::SetTime(pTime);
00427     }
00428 
00433     void Set(FbxTime pTime, float pValue)
00434     {
00435         FbxAnimCurveKeyBase::SetTime(pTime);
00436         mImpl->Set(pTime, pValue);
00437     }
00438 
00450     void SetTCB(FbxTime pTime, float pValue, float pData0 = 0.0f, float pData1 = 0.0f, float pData2 = 0.0f)
00451     {
00452         FbxAnimCurveKeyBase::SetTime(pTime);
00453         mImpl->SetTCB(pTime, pValue, pData0, pData1, pData2);
00454     }
00455 
00459     float GetValue() const
00460     {
00461         return mImpl->GetValue();
00462     }
00463 
00467     void SetValue(float pValue)
00468     {
00469         mImpl->SetValue(pValue);
00470     }
00471 
00472 
00476     FbxAnimCurveDef::EInterpolationType GetInterpolation()
00477     {
00478         return mImpl->GetInterpolation();
00479     }
00480 
00484     void SetInterpolation (FbxAnimCurveDef::EInterpolationType pInterpolation)
00485     {
00486         mImpl->SetInterpolation(pInterpolation);
00487     }
00488 
00495     FbxAnimCurveDef::ETangentMode GetTangentMode(bool pIncludeOverrides = false)
00496     {
00497         return mImpl->GetTangentMode(pIncludeOverrides);
00498     }
00499 
00503     void SetTangentMode (FbxAnimCurveDef::ETangentMode pTangentMode)
00504     {
00505         mImpl->SetTangentMode(pTangentMode);
00506     }
00507 
00512     FbxAnimCurveDef::EWeightedMode GetTangentWeightMode() const
00513     {
00514         return mImpl->GetTangentWeightMode();
00515     }
00516 
00550     void SetTangentWeightMode(FbxAnimCurveDef::EWeightedMode pTangentWeightMode, FbxAnimCurveDef::EWeightedMode pMask = FbxAnimCurveDef::eWeightedAll )
00551     {
00552         mImpl->SetTangentWeightMode(pTangentWeightMode, pMask);
00553     }
00554 
00555 
00560     FbxAnimCurveDef::EVelocityMode GetTangentVelocityMode() const
00561     {
00562         return mImpl->GetTangentVelocityMode();
00563     }
00564 
00574     void SetTangentVelocityMode(FbxAnimCurveDef::EVelocityMode pTangentVelocityMode, FbxAnimCurveDef::EVelocityMode pMask = FbxAnimCurveDef::eVelocityAll )
00575     {
00576         mImpl->SetTangentVelocityMode(pTangentVelocityMode, pMask);
00577     }
00578 
00584     FbxAnimCurveDef::EConstantMode GetConstantMode() const
00585     {
00586         return mImpl->GetConstantMode();
00587     }
00588 
00593     void SetConstantMode(FbxAnimCurveDef::EConstantMode pMode)
00594     {
00595         mImpl->SetConstantMode(pMode);
00596     }
00597 
00616     float GetDataFloat(FbxAnimCurveDef::EDataIndex pIndex) const
00617     {
00618         return mImpl->GetDataFloat(pIndex);
00619     }
00620 
00636     void SetDataFloat(FbxAnimCurveDef::EDataIndex pIndex, float pValue)
00637     {
00638         mImpl->SetDataFloat(pIndex, pValue);
00639     }
00640 
00645     void    SetTangentVisibility (FbxAnimCurveDef::ETangentVisibility pVisibility)
00646     {
00647         mImpl->SetTangentVisibility(pVisibility);
00648     }
00649 
00654     FbxAnimCurveDef::ETangentVisibility GetTangentVisibility () const
00655     {
00656         return mImpl->GetTangentVisibility();
00657     }
00658 
00665     void SetBreak(bool pVal)
00666     {
00667         mImpl->SetBreak(pVal);
00668     }
00669 
00676     bool GetBreak() const
00677     {
00678         return mImpl->GetBreak();
00679     }
00680 
00684     FbxAnimCurveKey_Impl* GetImpl() const
00685     {
00686         return mImpl;
00687     }
00688 
00692     static void SetAllocatorFct(FbxAnimCurveKey_Impl* (*pAllocatorFct)());
00693 
00697     static void SetCopyAllocatorFct(FbxAnimCurveKey_Impl* (*pCopyAllocatorFct)(FbxAnimCurveKey_Impl*));
00698 
00702     static void SetDeallocatorFct(void (*pDeallocatorFct)(FbxAnimCurveKey_Impl*));
00703 
00704 private:
00705     static FbxAnimCurveKey_Impl* (*mAllocatorFct)();
00706     static FbxAnimCurveKey_Impl* (*mCopyAllocatorFct)(FbxAnimCurveKey_Impl*);
00707     static void (*mDeallocatorFct)(FbxAnimCurveKey_Impl*);
00708     FbxAnimCurveKey_Impl* mImpl;
00709 };
00710 
00711 
00712 class FbxScene;
00778 class FBXSDK_DLL FbxAnimCurve : public FbxAnimCurveBase
00779 {
00780     FBXSDK_ABSTRACT_OBJECT_DECLARE(FbxAnimCurve, FbxAnimCurveBase);
00781 
00782 public:
00793     static FbxAnimCurve* Create(FbxScene* pContainer, char const *pName);
00795 
00804     virtual void ResizeKeyBuffer(int pKeyCount) = 0;
00805 
00809     virtual void KeyModifyBegin () = 0;
00810         
00814     virtual void KeyModifyEnd () = 0;
00815 
00817     virtual void KeyClear () = 0;
00818 
00822     virtual int KeyGetCount () const = 0;
00823 
00841     virtual int KeyAdd (FbxTime pTime, FbxAnimCurveKeyBase& pKey, int* pLast = NULL) = 0; 
00842 
00857     virtual int KeyAdd (FbxTime pTime, int* pLast = NULL) = 0;
00858 
00867     virtual bool KeySet(int pIndex,  FbxAnimCurveKeyBase& pKey) = 0;
00868         
00873     virtual bool KeyRemove(int pIndex) = 0;
00874 
00880     virtual bool KeyRemove(int pStartIndex, int pEndIndex) = 0;
00881 
00897     virtual int KeyInsert ( FbxTime pTime, int* pLast = NULL ) = 0;
00898         
00912     virtual double KeyFind (FbxTime pTime, int* pLast = NULL) = 0;
00913 
00918     virtual bool KeyScaleValue (float pMultValue) = 0;
00919 
00924     virtual bool KeyScaleValueAndTangent (float pMultValue) = 0;
00926 
00949     virtual void KeySet(int pKeyIndex,FbxTime pTime, float pValue, FbxAnimCurveDef::EInterpolationType pInterpolation = FbxAnimCurveDef::eInterpolationCubic, FbxAnimCurveDef::ETangentMode pTangentMode = FbxAnimCurveDef::eTangentAuto, float pData0 = 0.0,float pData1 = 0.0,FbxAnimCurveDef::EWeightedMode pTangentWeightMode = FbxAnimCurveDef::eWeightedNone, float pWeight0 = FbxAnimCurveDef::sDEFAULT_WEIGHT,float pWeight1 = FbxAnimCurveDef::sDEFAULT_WEIGHT,float pVelocity0 = FbxAnimCurveDef::sDEFAULT_VELOCITY,float pVelocity1 = FbxAnimCurveDef::sDEFAULT_VELOCITY) = 0;
00950 
00963     virtual void KeySetTCB(int pKeyIndex,FbxTime pTime, float pValue, float pData0 = 0.0f, float pData1 = 0.0f, float pData2 = 0.0f) = 0;
00964 
00969     virtual FbxAnimCurveDef::EInterpolationType KeyGetInterpolation(int pKeyIndex) const = 0;
00970 
00975     virtual void KeySetInterpolation(int pKeyIndex, FbxAnimCurveDef::EInterpolationType pInterpolation) = 0;
00976 
00983     virtual FbxAnimCurveDef::EConstantMode KeyGetConstantMode(int pKeyIndex) const = 0;
00984 
00992     virtual FbxAnimCurveDef::ETangentMode KeyGetTangentMode(int pKeyIndex, bool pIncludeOverrides = false ) const = 0;
00993 
00999     virtual void KeySetConstantMode(int pKeyIndex, FbxAnimCurveDef::EConstantMode pMode) = 0;
01000 
01006     virtual void KeySetTangentMode(int pKeyIndex, FbxAnimCurveDef::ETangentMode pTangent) = 0;
01007 
01014     virtual FbxAnimCurveKey KeyGet(int pIndex) const = 0;
01015 
01020     virtual float KeyGetValue(int pKeyIndex) const = 0;
01021 
01026     virtual void KeySetValue(int pKeyIndex, float pValue) = 0;
01027 
01032     virtual void KeyIncValue(int pKeyIndex, float pValue) = 0;
01033 
01039     virtual void KeyMultValue(int pKeyIndex, float pValue) = 0;
01040 
01047     virtual void KeyMultTangent(int pKeyIndex, float pValue) = 0;
01048 
01053     virtual FbxTime KeyGetTime(int pKeyIndex) const = 0;
01054 
01060     virtual void KeySetTime(int pKeyIndex, FbxTime pTime) = 0;
01061 
01068     virtual void KeySetBreak(int pKeyIndex, bool pVal) = 0; 
01069 
01076     virtual bool KeyGetBreak(int pKeyIndex) const = 0; 
01078 
01089     virtual float KeyGetLeftDerivative(int pIndex) = 0;
01090 
01100     virtual void KeySetLeftDerivative(int pIndex, float pValue) = 0;
01101 
01109     virtual float KeyGetLeftAuto(int pIndex, bool pApplyOvershootProtection = false) = 0;
01110 
01117     virtual FbxAnimCurveTangentInfo KeyGetLeftDerivativeInfo(int pIndex) = 0;
01118 
01130     virtual void KeySetLeftDerivativeInfo(int pIndex, const FbxAnimCurveTangentInfo& pValue, bool pForceDerivative = false) = 0;
01131 
01138     virtual float KeyGetRightDerivative(int pIndex) = 0;
01139 
01149     virtual void KeySetRightDerivative(int pIndex, float pValue) = 0;
01150 
01158     virtual float KeyGetRightAuto(int pIndex, bool pApplyOvershootProtection = false) = 0;
01159 
01166     virtual FbxAnimCurveTangentInfo KeyGetRightDerivativeInfo(int pIndex) = 0;
01167 
01179     virtual void KeySetRightDerivativeInfo(int pIndex, const FbxAnimCurveTangentInfo& pValue, bool pForceDerivative = false) = 0;
01180 
01187     virtual bool KeyIsLeftTangentWeighted(int pIndex) const = 0;
01188 
01195     virtual bool KeyIsRightTangentWeighted(int pIndex) const = 0;
01196 
01203     virtual float KeyGetLeftTangentWeight(int pIndex) const = 0;
01204 
01211     virtual float KeyGetRightTangentWeight(int pIndex) const = 0;
01212 
01224     virtual void   KeySetLeftTangentWeight( int pIndex, float pWeight, bool pAdjustTan = false ) = 0;
01225 
01237     virtual void   KeySetRightTangentWeight( int pIndex, float pWeight, bool pAdjustTan = false  ) = 0;
01238 
01245     virtual float KeyGetLeftTangentVelocity( int pIndex) const = 0;
01246 
01253     virtual float KeyGetRightTangentVelocity( int pIndex) const = 0;
01254 
01256 
01273     virtual float Evaluate (FbxTime pTime, int* pLast = NULL) = 0;
01274 
01286     virtual float EvaluateIndex( double pIndex) = 0;
01287         
01297     virtual float EvaluateLeftDerivative (FbxTime pTime, int* pLast = NULL) = 0;
01298         
01308     virtual float EvaluateRightDerivative (FbxTime pTime, int* pLast = NULL) = 0;
01310 
01321     virtual bool GetTimeInterval(FbxTimeSpan& pTimeInterval) = 0;
01322 
01323 
01328     virtual KFCurve* GetKFCurve() = 0;
01329 
01336     virtual void CopyFrom(FbxAnimCurve& pSource, bool pWithKeys = true) = 0;
01338 
01339 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01340 
01341     //  WARNING!
01342     //    Anything beyond these lines may not be documented accurately and is 
01343     //     subject to change without notice.
01345     virtual bool Store(FbxIO* pFileObject, bool pLegacyVersion=false) = 0;
01346     virtual bool Retrieve(FbxIO* pFileObject) = 0;
01347 
01348 protected:
01349     FbxAnimCurve(FbxManager& pManager, char const* pName);
01350 
01351     virtual void Construct(const FbxAnimCurveBase* pFrom);
01352     virtual void Destruct(bool pRecursive, bool pDependents);
01353 
01354 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
01355 };
01356 
01357 #include <fbxsdk/fbxsdk_nsend.h>
01358 
01359 #endif /* _FBXSDK_SCENE_ANIMATION_CURVE_H_ */