kfbxanimcurve.h

Go to the documentation of this file.
00001 /****************************************************************************************
00002 
00003 Copyright (C) 2010 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 
00015 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXANIMCURVE_H
00016 #define FBXFILESDK_KFBXPLUGINS_KFBXANIMCURVE_H
00017 
00018 #include <fbxfilesdk/components/kfcurve/kfcurve.h>
00019 #include <fbxfilesdk/kfbxplugins/kfbxanimcurvebase.h>
00020 #include <fbxfilesdk/kfbxplugins/kfbxobject.h>
00021 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00022 
00026 class KFBX_DLL KFbxAnimCurveDef {
00027 
00028 public:
00029     static const int   sWEIGHT_DIVIDER = 9999; // precise enough and can be divided by 3 without error
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     typedef enum {
00038         eTANGENT_AUTO                     = KFCURVE_TANGEANT_AUTO,
00040         eTANGENT_TCB                      = KFCURVE_TANGEANT_TCB,
00042         eTANGENT_USER                     = KFCURVE_TANGEANT_USER,
00044         eTANGENT_BREAK                    = KFCURVE_TANGEANT_BREAK,
00046         eTANGENT_AUTO_BREAK               = KFCURVE_TANGEANT_AUTO_BREAK,
00048         eTANGENT_GENERIC_CLAMP            = KFCURVE_GENERIC_CLAMP,
00050         eTANGENT_GENERIC_CLAMP_PROGRESSIVE= KFCURVE_GENERIC_CLAMP_PROGRESSIVE,
00052         eTANGENT_GENERIC_TIME_INDEPENDENT = KFCURVE_GENERIC_TIME_INDEPENDENT
00053 
00054     } ETangentMode;
00055 
00057     typedef enum {
00059         eINTERPOLATION_CONSTANT = KFCURVE_INTERPOLATION_CONSTANT,
00061         eINTERPOLATION_LINEAR   = KFCURVE_INTERPOLATION_LINEAR,
00063         eINTERPOLATION_CUBIC    = KFCURVE_INTERPOLATION_CUBIC,
00065         eINTERPOLATION_ALL      = KFCURVE_INTERPOLATION_ALL
00066     } EInterpolationType;
00067 
00069     typedef enum {
00071         eWEIGHTED_NONE      = KFCURVE_WEIGHTED_NONE,
00073         eWEIGHTED_RIGHT     = KFCURVE_WEIGHTED_RIGHT,
00075         eWEIGHTED_NEXT_LEFT = KFCURVE_WEIGHTED_NEXT_LEFT,
00077         eWEIGHTED_ALL       = KFCURVE_WEIGHTED_ALL
00078     } EWeightedMode;
00079 
00081     typedef enum {
00083         eCONSTANT_STANDARD  = KFCURVE_CONSTANT_STANDARD,
00085         eCONSTANT_NEXT      = KFCURVE_CONSTANT_NEXT,
00087         eCONSTANT_ALL       = KFCURVE_CONSTANT_ALL
00088     } EConstantMode;
00089 
00091     typedef enum {
00093         eVELOCITY_NONE  =       KFCURVE_VELOCITY_NONE,
00095         eVELOCITY_RIGHT =       KFCURVE_VELOCITY_RIGHT,
00097         eVELOCITY_NEXT_LEFT =   KFCURVE_VELOCITY_NEXT_LEFT,
00099         eVELOCITY_ALL       =   KFCURVE_VELOCITY_ALL
00100     } EVelocityMode;
00101 
00104     typedef enum {
00106         eTANGENT_SHOW_NONE      = KFCURVE_TANGEANT_SHOW_NONE,
00108         eTANGENT_SHOW_LEFT      = KFCURVE_TANGEANT_SHOW_LEFT,
00110         eTANGENT_SHOW_RIGHT     = KFCURVE_TANGEANT_SHOW_RIGHT,
00112         eTANGENT_SHOW_BOTH      = KFCURVE_TANGEANT_SHOW_BOTH
00113     } ETangentVisibility;
00114 
00116     typedef enum {
00118         eRIGHT_SLOPE            = KFCURVEKEY_RIGHT_SLOPE, 
00121         eNEXT_LEFT_SLOPE        = KFCURVEKEY_NEXT_LEFT_SLOPE, 
00122 
00124         eWEIGHTS                = KFCURVEKEY_WEIGHTS, 
00126         eRIGHT_WEIGHT           = KFCURVEKEY_RIGHT_WEIGHT, 
00128         eNEXT_LEFT_WEIGHT       = KFCURVEKEY_NEXT_LEFT_WEIGHT, 
00129 
00131         eVELOCITY               = KFCURVEKEY_VELOCITY,
00133         eRIGHT_VELOCITY         = KFCURVEKEY_RIGHT_VELOCITY,
00135         eNEXT_LEFT_VELOCITY     = KFCURVEKEY_NEXT_LEFT_VELOCITY, 
00136 
00138         eTCB_TENSION            = KFCURVEKEY_TCB_TENSION, 
00140         eTCB_CONTINUITY         = KFCURVEKEY_TCB_CONTINUITY, 
00142         eTCB_BIAS               = KFCURVEKEY_TCB_BIAS,
00143 
00144     } EKFbxAnimCurveDataIndex;
00145 };
00146 
00157 class KFBX_DLL KFbxAnimCurveKeyImpl
00158 {
00159 public:
00162     virtual ~KFbxAnimCurveKeyImpl() {};
00163 
00166     virtual KFbxAnimCurveKeyImpl& operator=(const KFbxAnimCurveKeyImpl& pFKey) = 0;
00167 
00172     virtual void Set(KTime pTime, float pValue) = 0;
00173 
00185     virtual void SetTCB(KTime pTime, float pValue, float pData0 = 0.0f, float pData1 = 0.0f, float pData2 = 0.0f) = 0;
00186 
00190     virtual float GetValue() const = 0;
00191 
00195     virtual void SetValue(float pValue) = 0;
00196 
00200     virtual KFbxAnimCurveDef::EInterpolationType GetInterpolation() const = 0;
00201 
00205     virtual void SetInterpolation (KFbxAnimCurveDef::EInterpolationType pInterpolation) = 0;
00206 
00213     virtual KFbxAnimCurveDef::ETangentMode GetTangentMode(bool pIncludeOverrides = false) const = 0;
00214 
00218     virtual void SetTangentMode (KFbxAnimCurveDef::ETangentMode pTangentMode) = 0;
00219 
00224     virtual KFbxAnimCurveDef::EWeightedMode GetTangentWeightMode() const = 0;
00225 
00259     virtual void SetTangentWeightMode(KFbxAnimCurveDef::EWeightedMode pTangentWeightMode, KFbxAnimCurveDef::EWeightedMode pMask = KFbxAnimCurveDef::eWEIGHTED_ALL ) = 0;
00260 
00265     virtual KFbxAnimCurveDef::EVelocityMode GetTangentVelocityMode() const = 0;
00266 
00276     virtual void SetTangentVelocityMode(KFbxAnimCurveDef::EVelocityMode pTangentVelocityMode, KFbxAnimCurveDef::EVelocityMode pMask = KFbxAnimCurveDef::eVELOCITY_ALL ) = 0;
00277 
00283     virtual KFbxAnimCurveDef::EConstantMode GetConstantMode() const = 0;
00284 
00289     virtual void SetConstantMode(KFbxAnimCurveDef::EConstantMode pMode) = 0;
00290 
00309     virtual float GetDataFloat(KFbxAnimCurveDef::EKFbxAnimCurveDataIndex pIndex) const = 0;
00310 
00311 
00312 
00328     virtual void SetDataFloat(KFbxAnimCurveDef::EKFbxAnimCurveDataIndex pIndex, float pValue) = 0;
00329 
00334     virtual void    SetTangentVisibility (KFbxAnimCurveDef::ETangentVisibility pVisibility) = 0;    
00335 
00340     virtual KFbxAnimCurveDef::ETangentVisibility GetTangentVisibility () const = 0;
00341 
00348     virtual void SetBreak(bool pVal) = 0; 
00349 
00356     virtual bool GetBreak() const = 0; 
00357 };
00358 
00372 class KFBX_DLL KFbxAnimCurveKey : public KFbxAnimCurveKeyBase
00373 {
00374 
00375 public:
00376 
00379     KFbxAnimCurveKey() : KFbxAnimCurveKeyBase()
00380     {
00381         K_ASSERT(mAllocatorFct != NULL);
00382         mImpl = (*mAllocatorFct)();
00383     }
00384 
00388     KFbxAnimCurveKey(KTime pTime) : KFbxAnimCurveKeyBase()
00389     {
00390         K_ASSERT(mAllocatorFct != NULL);
00391         mImpl = (*mAllocatorFct)();
00392         SetTime(pTime);
00393     }
00394 
00399     KFbxAnimCurveKey(KTime pTime, float pVal) : KFbxAnimCurveKeyBase()
00400     {
00401         K_ASSERT(mAllocatorFct != NULL);
00402         mImpl = (*mAllocatorFct)();
00403         Set(pTime, pVal);
00404     }
00405 
00408     KFbxAnimCurveKey(KFbxAnimCurveKey const& pFKey) : KFbxAnimCurveKeyBase()
00409     {
00410         K_ASSERT(mCopyAllocatorFct != NULL);
00411         SetTime(pFKey.GetTime());
00412         mImpl = mCopyAllocatorFct(pFKey.GetImpl());
00413     }
00414 
00417     ~KFbxAnimCurveKey()
00418     {
00419         K_ASSERT(mDeallocatorFct != NULL);
00420         (*mDeallocatorFct)(mImpl);
00421     }
00422 
00425     KFbxAnimCurveKey& operator=(const KFbxAnimCurveKey& pFKey)
00426     {
00427         K_ASSERT(mImpl);
00428         if (mImpl)
00429         {
00430             *mImpl = *(pFKey.GetImpl());
00431         }
00432         SetTime(pFKey.GetTime());
00433         return *this;
00434     }
00435 
00439     KTime GetTime() const
00440     {
00441         return KFbxAnimCurveKeyBase::GetTime();
00442     }
00443 
00447     void SetTime(const KTime& pTime)
00448     {
00449         KFbxAnimCurveKeyBase::SetTime(pTime);
00450     }
00451 
00456     void Set(KTime pTime, float pValue)
00457     {
00458         KFbxAnimCurveKeyBase::SetTime(pTime);
00459         mImpl->Set(pTime, pValue);
00460     }
00461 
00473     void SetTCB(KTime pTime, float pValue, float pData0 = 0.0f, float pData1 = 0.0f, float pData2 = 0.0f)
00474     {
00475         KFbxAnimCurveKeyBase::SetTime(pTime);
00476         mImpl->SetTCB(pTime, pValue, pData0, pData1, pData2);
00477     }
00478 
00482     float GetValue() const
00483     {
00484         return mImpl->GetValue();
00485     }
00486 
00490     void SetValue(float pValue)
00491     {
00492         mImpl->SetValue(pValue);
00493     }
00494 
00498     KFbxAnimCurveDef::EInterpolationType GetInterpolation()
00499     {
00500         return mImpl->GetInterpolation();
00501     }
00502 
00506     void SetInterpolation (KFbxAnimCurveDef::EInterpolationType pInterpolation)
00507     {
00508         mImpl->SetInterpolation(pInterpolation);
00509     }
00510 
00517     KFbxAnimCurveDef::ETangentMode GetTangentMode(bool pIncludeOverrides = false)
00518     {
00519         return mImpl->GetTangentMode(pIncludeOverrides);
00520     }
00521 
00525     void SetTangentMode (KFbxAnimCurveDef::ETangentMode pTangentMode)
00526     {
00527         mImpl->SetTangentMode(pTangentMode);
00528     }
00529 
00534     KFbxAnimCurveDef::EWeightedMode GetTangentWeightMode() const
00535     {
00536         return mImpl->GetTangentWeightMode();
00537     }
00538 
00572     void SetTangentWeightMode(KFbxAnimCurveDef::EWeightedMode pTangentWeightMode, KFbxAnimCurveDef::EWeightedMode pMask = KFbxAnimCurveDef::eWEIGHTED_ALL )
00573     {
00574         mImpl->SetTangentWeightMode(pTangentWeightMode, pMask);
00575     }
00576 
00577 
00582     KFbxAnimCurveDef::EVelocityMode GetTangentVelocityMode() const
00583     {
00584         return mImpl->GetTangentVelocityMode();
00585     }
00586 
00596     void SetTangentVelocityMode(KFbxAnimCurveDef::EVelocityMode pTangentVelocityMode, KFbxAnimCurveDef::EVelocityMode pMask = KFbxAnimCurveDef::eVELOCITY_ALL )
00597     {
00598         mImpl->SetTangentVelocityMode(pTangentVelocityMode, pMask);
00599     }
00600 
00606     KFbxAnimCurveDef::EConstantMode GetConstantMode() const
00607     {
00608         return mImpl->GetConstantMode();
00609     }
00610 
00615     void SetConstantMode(KFbxAnimCurveDef::EConstantMode pMode)
00616     {
00617         mImpl->SetConstantMode(pMode);
00618     }
00619 
00638     float GetDataFloat(KFbxAnimCurveDef::EKFbxAnimCurveDataIndex pIndex) const
00639     {
00640         return mImpl->GetDataFloat(pIndex);
00641     }
00642 
00658     void SetDataFloat(KFbxAnimCurveDef::EKFbxAnimCurveDataIndex pIndex, float pValue)
00659     {
00660         mImpl->SetDataFloat(pIndex, pValue);
00661     }
00662 
00667     void    SetTangentVisibility (KFbxAnimCurveDef::ETangentVisibility pVisibility)
00668     {
00669         mImpl->SetTangentVisibility(pVisibility);
00670     }
00671 
00676     KFbxAnimCurveDef::ETangentVisibility GetTangentVisibility () const
00677     {
00678         return mImpl->GetTangentVisibility();
00679     }
00680 
00687     void SetBreak(bool pVal)
00688     {
00689         mImpl->SetBreak(pVal);
00690     }
00691 
00698     bool GetBreak() const
00699     {
00700         return mImpl->GetBreak();
00701     }
00702 
00706     KFbxAnimCurveKeyImpl* GetImpl() const
00707     {
00708         return mImpl;
00709     }
00710 
00714     static void SetAllocatorFct(KFbxAnimCurveKeyImpl* (*pAllocatorFct)());
00715 
00719     static void SetCopyAllocatorFct(KFbxAnimCurveKeyImpl* (*pCopyAllocatorFct)(KFbxAnimCurveKeyImpl*));
00720 
00724     static void SetDeallocatorFct(void (*pDeallocatorFct)(KFbxAnimCurveKeyImpl*));
00725 
00726 private:
00727     static KFbxAnimCurveKeyImpl* (*mAllocatorFct)();
00728     static KFbxAnimCurveKeyImpl* (*mCopyAllocatorFct)(KFbxAnimCurveKeyImpl*);
00729     static void (*mDeallocatorFct)(KFbxAnimCurveKeyImpl*);
00730     KFbxAnimCurveKeyImpl* mImpl;
00731 };
00732 
00733 
00734 class KFbxScene;
00800 class KFBX_DLL KFbxAnimCurve : public KFbxAnimCurveBase
00801 {
00802     KFBXOBJECT_DECLARE_ABSTRACT(KFbxAnimCurve, KFbxAnimCurveBase);
00803 
00804 public:
00805 
00816     static KFbxAnimCurve* Create(KFbxScene* pContainer, char const *pName);
00818 
00827     virtual void ResizeKeyBuffer(int pKeyCount) = 0;
00828 
00832     virtual void KeyModifyBegin () = 0;
00833         
00837     virtual void KeyModifyEnd () = 0;
00838 
00840     virtual void KeyClear () = 0;
00841 
00845     virtual int KeyGetCount () const = 0;
00846 
00864     virtual int KeyAdd (KTime pTime, KFbxAnimCurveKeyBase& pKey, int* pLast = NULL) = 0; 
00865 
00880     virtual int KeyAdd (KTime pTime, int* pLast = NULL) = 0;
00881 
00890     virtual bool KeySet(int pIndex,  KFbxAnimCurveKeyBase& pKey) = 0;
00891         
00896     virtual bool KeyRemove(int pIndex) = 0;
00897 
00903     virtual bool KeyRemove(int pStartIndex, int pEndIndex) = 0;
00904 
00920     virtual int KeyInsert ( KTime pTime, int* pLast = NULL ) = 0;
00921         
00935     virtual double KeyFind (KTime pTime, int* pLast = NULL) = 0;
00936 
00941     virtual bool KeyScaleValue (float pMultValue) = 0;
00942 
00947     virtual bool KeyScaleValueAndTangent (float pMultValue) = 0;
00949 
00972     virtual void KeySet(int pKeyIndex,KTime pTime, float pValue, KFbxAnimCurveDef::EInterpolationType pInterpolation = KFbxAnimCurveDef::eINTERPOLATION_CUBIC, KFbxAnimCurveDef::ETangentMode pTangentMode = KFbxAnimCurveDef::eTANGENT_AUTO, float pData0 = 0.0,float pData1 = 0.0,KFbxAnimCurveDef::EWeightedMode pTangentWeightMode = KFbxAnimCurveDef::eWEIGHTED_NONE, float pWeight0 = KFbxAnimCurveDef::sDEFAULT_WEIGHT,float pWeight1 = KFbxAnimCurveDef::sDEFAULT_WEIGHT,float pVelocity0 = KFbxAnimCurveDef::sDEFAULT_VELOCITY,float pVelocity1 = KFbxAnimCurveDef::sDEFAULT_VELOCITY) = 0;
00973 
00986     virtual void KeySetTCB(int pKeyIndex,KTime pTime, float pValue, float pData0 = 0.0f, float pData1 = 0.0f, float pData2 = 0.0f) = 0;
00987 
00992     virtual KFbxAnimCurveDef::EInterpolationType KeyGetInterpolation(int pKeyIndex) const = 0;
00993 
00998     virtual void KeySetInterpolation(int pKeyIndex, KFbxAnimCurveDef::EInterpolationType pInterpolation) = 0;
00999 
01006     virtual KFbxAnimCurveDef::EConstantMode KeyGetConstantMode(int pKeyIndex) const = 0;
01007 
01015     virtual KFbxAnimCurveDef::ETangentMode KeyGetTangentMode(int pKeyIndex, bool pIncludeOverrides = false ) const = 0;
01016 
01022     virtual void KeySetConstantMode(int pKeyIndex, KFbxAnimCurveDef::EConstantMode pMode) = 0;
01023 
01029     virtual void KeySetTangentMode(int pKeyIndex, KFbxAnimCurveDef::ETangentMode pTangent) = 0;
01030 
01037     virtual KFbxAnimCurveKey KeyGet(int pIndex) const = 0;
01038 
01043     virtual float KeyGetValue(int pKeyIndex) const = 0;
01044 
01049     virtual void KeySetValue(int pKeyIndex, float pValue) = 0;
01050 
01055     virtual void KeyIncValue(int pKeyIndex, float pValue) = 0;
01056 
01062     virtual void KeyMultValue(int pKeyIndex, float pValue) = 0;
01063 
01070     virtual void KeyMultTangent(int pKeyIndex, float pValue) = 0;
01071 
01076     virtual KTime KeyGetTime(int pKeyIndex) const = 0;
01077 
01083     virtual void KeySetTime(int pKeyIndex, KTime pTime) = 0;
01084 
01091     virtual void KeySetBreak(int pKeyIndex, bool pVal) = 0; 
01092 
01099     virtual bool KeyGetBreak(int pKeyIndex) const = 0; 
01101 
01112     virtual float KeyGetLeftDerivative(int pIndex) = 0;
01113 
01123     virtual void KeySetLeftDerivative(int pIndex, float pValue) = 0;
01124 
01132     virtual float KeyGetLeftAuto(int pIndex, bool pApplyOvershootProtection = false) = 0;
01133 
01140     virtual KFCurveTangeantInfo KeyGetLeftDerivativeInfo(int pIndex) = 0;
01141 
01153     virtual void KeySetLeftDerivativeInfo(kFCurveIndex pIndex, KFCurveTangeantInfo pValue, bool pForceDerivative = false) = 0;
01154 
01161     virtual float KeyGetRightDerivative(int pIndex) = 0;
01162 
01172     virtual void KeySetRightDerivative(int pIndex, float pValue) = 0;
01173 
01181     virtual float KeyGetRightAuto(int pIndex, bool pApplyOvershootProtection = false) = 0;
01182 
01189     virtual KFCurveTangeantInfo KeyGetRightDerivativeInfo(int pIndex) = 0;
01190 
01202     virtual void KeySetRightDerivativeInfo(kFCurveIndex pIndex, KFCurveTangeantInfo pValue, bool pForceDerivative = false) = 0;
01203 
01210     virtual bool KeyIsLeftTangentWeighted(int pIndex) const = 0;
01211 
01218     virtual bool KeyIsRightTangentWeighted(int pIndex) const = 0;
01219 
01226     virtual float KeyGetLeftTangentWeight(int pIndex) const = 0;
01227 
01234     virtual float KeyGetRightTangentWeight(int pIndex) const = 0;
01235 
01247     virtual void   KeySetLeftTangentWeight( int pIndex, float pWeight, bool pAdjustTan = false ) = 0;
01248 
01260     virtual void   KeySetRightTangentWeight( int pIndex, float pWeight, bool pAdjustTan = false  ) = 0;
01261 
01268     virtual float KeyGetLeftTangentVelocity( int pIndex) const = 0;
01269 
01276     virtual float KeyGetRightTangentVelocity( int pIndex) const = 0;
01277 
01279 
01296     virtual float Evaluate (KTime pTime, int* pLast = NULL) = 0;
01297 
01309     virtual float EvaluateIndex( double pIndex) = 0;
01310         
01320     virtual float EvaluateLeftDerivative (KTime pTime, int* pLast = NULL) = 0;
01321         
01331     virtual float EvaluateRightDerivative (KTime pTime, int* pLast = NULL) = 0;
01333 
01346     virtual bool GetTimeInterval(KTime& pStart, KTime& pStop) = 0;
01347 
01353     virtual bool GetTimeInterval(KTimeSpan& pTimeInterval) = 0;
01354 
01355 
01360     virtual KFCurve* GetKFCurve() = 0;
01361 
01368     virtual void CopyFrom(KFbxAnimCurve& pSource, bool pWithKeys = true) = 0;
01370 
01371 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01372 
01373     //  WARNING!
01374     //    Anything beyond these lines may not be documented accurately and is 
01375     //     subject to change without notice.
01377 
01378     virtual bool Store(KFbx* pFileObject) = 0;
01379     virtual bool Retrieve(KFbx* pFileObject) = 0;
01380 
01381 protected:
01382     KFbxAnimCurve(KFbxSdkManager& pManager, char const* pName);
01383 
01384     virtual void Construct(const KFbxAnimCurveBase* pFrom);
01385     virtual void Destruct(bool pRecursive, bool pDependents);
01386 
01387 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
01388 };
01389 
01390 #include <fbxfilesdk/fbxfilesdk_nsend.h>
01391 
01392 #endif // FBXFILESDK_KFBXPLUGINS_KFBXANIMCURVE_H