fbxsdk/scene/animation/fbxanimutilities.h Source File
 
 
 
fbxsdk/scene/animation/fbxanimutilities.h
Go to the documentation of this file.
00001 /****************************************************************************************
00002  
00003    Copyright (C) 2013 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_UTILITIES_H_
00014 #define _FBXSDK_SCENE_ANIMATION_UTILITIES_H_
00015 
00016 #include <fbxsdk/fbxsdk_def.h>
00017 
00018 #include <fbxsdk/core/base/fbxarray.h>
00019 #include <fbxsdk/core/base/fbxstring.h>
00020 #include <fbxsdk/core/base/fbxtime.h>
00021 #include <fbxsdk/scene/animation/fbxanimcurve.h>
00022 
00023 #include <fbxsdk/fbxsdk_nsbegin.h>
00024 
00025 class FbxSet;
00026 class FbxObject;
00027 class FbxProperty;
00028 class FbxScene;
00029 class FbxIO;
00030 class FbxAnimStack;
00031 class FbxAnimLayer;
00032 class FbxAnimCurveNode;
00033 class FbxAnimCurve;
00034 
00035 class FBXSDK_DLL FbxAnimUtilities
00036 {
00037 public:
00043         static bool IsAnimated(FbxObject* pObj);
00044 
00052         static bool IsChannelAnimated(FbxObject* pObj, const char* pPropertyName, const char* pChannelName = NULL);
00053 
00054     class FBXSDK_DLL FbxAnimSplitDef
00055     {
00056     public:
00057         FbxString mName;
00058         FbxTime   mStart;
00059         FbxTime   mEnd;
00060         
00061         FbxAnimSplitDef()
00062         {
00063             mName = "unnamed";
00064             mStart = 0;
00065             mEnd = 0;
00066         }
00067         
00068         FbxAnimSplitDef(const FbxString& pName, FbxTime& pStart, FbxTime& pEnd)
00069         {
00070             mName = pName;
00071             mStart = pStart;
00072             mEnd = pEnd;
00073         }
00074         
00075         FbxAnimSplitDef& operator =(const FbxAnimSplitDef& pRhs)
00076         {
00077             mName = pRhs.mName;
00078             mStart = pRhs.mStart;
00079             mEnd = pRhs.mEnd;
00080             return *this;
00081         }
00082     } ;
00083 
00084     class FBXSDK_DLL CurveNodeIntfce
00085     {
00086     public:
00087         // pData is a pointer to the private KFCurveNode
00088         CurveNodeIntfce(void* pData);
00089         ~CurveNodeIntfce();
00090 
00091         FbxHandle GetHandle();
00092 
00093         char*            GetTimeWarpName() const;
00094         CurveNodeIntfce  GetTimeWarp();
00095 
00096         CurveNodeIntfce  GetLayer(int pId);
00097 
00098         int              GetCount();
00099         void*            GetHandle(unsigned int pId);
00100         void*            GetCurveHandle(int pId = -1);
00101         void             SetCurveHandle(void* pCurveHandle, int pId = -1);
00102         CurveNodeIntfce  FindRecursive(const char* pName);
00103 
00104         bool IsValid() { return mImp != NULL; }        
00105         CurveNodeIntfce& operator=(CurveNodeIntfce& lRhs)
00106         {
00107             mImp = lRhs.mImp;
00108             return *this;
00109         }
00110 
00111         bool operator==(CurveNodeIntfce& lRhs)
00112         {
00113             return (mImp == lRhs.mImp);
00114         }
00115 
00116     private:
00117         friend class FbxAnimUtilities;
00118         void* mImp;
00119     };
00120 
00121     class FBXSDK_DLL CurveIntfce
00122     {
00123     public:
00124         // pData is a pointer to the private KFCurve
00125         CurveIntfce(void* pData);
00126         CurveIntfce(FbxAnimCurve* pAnimCurve);
00127         ~CurveIntfce();
00128 
00129         float GetValue();
00130         void  SetValue(float pVal);
00131         int   KeyGetCount();
00132 
00133         void* GetCurveHandle();
00134         void  SetCurveHandle(void* pData);
00135 
00136         int GetPreExtrapolation();
00137         int GetPreExtrapolationCount();
00138         int GetPostExtrapolation();
00139         int GetPostExtrapolationCount();
00140 
00141 
00142         bool IsValid() { return mImp != NULL; }    
00143         CurveIntfce& operator=(CurveIntfce& lRhs)
00144         {
00145             mImp = lRhs.mImp;
00146             mIsAnimCurveImp = lRhs.mIsAnimCurveImp;
00147             return *this;
00148         }
00149 
00150         bool operator==(CurveIntfce& lRhs)
00151         {
00152             return (mImp == lRhs.mImp);
00153         }
00154 
00155     private:
00156         friend class FbxAnimUtilities;
00157 
00158         void* mImp;
00159         bool  mIsAnimCurveImp;
00160     };
00161 
00162     static int SplitAnimationIntoMultipleStacks(FbxScene* pScene, const FbxArray<FbxAnimSplitDef*>& pAnimSplitDefinitions, const FbxAnimStack* pSrcAnimStack, FbxArray<FbxAnimStack*>& pDstStacks);
00163     static void ShareAnimCurves(FbxProperty& pDstProperty, FbxProperty& pSrcProperty, FbxScene* pScene);
00164 
00165     // Encapsulate use of private animation data
00166     static void             SetTimeWarpSet(FbxSet* pTWset);
00167 
00168     static CurveNodeIntfce  CreateCurveNode(const char* pName);
00169     static CurveNodeIntfce  CreateCurveNode(FbxIO* pFileObject);
00170     static CurveNodeIntfce  CreateCurveNode(FbxIO* pFileObject, CurveNodeIntfce& pParent, bool pOnlyDefaults = false);
00171     static CurveNodeIntfce  CreateTimeWarpNode(FbxAnimCurve* pAnimCurve, const char* pFalloffName);
00172     
00173     static CurveNodeIntfce  GrabCurveNode(FbxAnimCurveNode* pCN);
00174     static void             RestrieveCurveNode(CurveNodeIntfce& pData, FbxIO* mFileObject);
00175     static void             StoreCurveNode(CurveNodeIntfce& pData, FbxIO* mFileObject);
00176     static void             ReleaseCurveNode(FbxAnimCurveNode* pCurveNode);
00177     static void             DestroyCurveNode(CurveNodeIntfce& pData);
00178     static void             DestroyCurve(CurveIntfce& pData);
00179 
00180     static void             ConnectTimeWarp(FbxAnimCurveNode* pCurveNode, CurveNodeIntfce& pData, FbxSet& pTimeWarpsKFCurveNodes);
00181     static void             MergeLayerAndTimeWarp(FbxObject* pObj, FbxAnimLayer* pAnimLayer);
00182 
00183     static void             CopyFrom(FbxAnimCurve* pAC, CurveIntfce& pFC);
00184     static bool             CompareCurves(FbxAnimCurve* pAC1, FbxAnimCurve* pAC2); 
00185 
00186     static void             Resample(FbxAnimCurve &pSourceCurve, FbxAnimCurve &pTargetCurve, FbxTime &pStart, FbxTime &pStop, FbxTime &pPeriod, FbxAnimCurveDef::EInterpolationType pInterpolation, FbxAnimCurveDef::ETangentMode pTangentMode, bool pAddStopKey = false);
00187     static void             Resample(FbxAnimCurve &pSourceCurve, FbxAnimCurve &pTargetCurve, FbxTime &pStart, FbxTime &pStop, FbxTime &pPeriod, bool pAddStopKey = false);
00188     static void             Resample(FbxAnimCurve &pCurve, FbxTime pPeriod, FbxTime pStart = FBXSDK_TIME_MINUS_INFINITE, FbxTime   pStop = FBXSDK_TIME_INFINITE, bool pKeysOnFrame = false);
00189 };
00190  
00191 #include <fbxsdk/fbxsdk_nsend.h>
00192 
00193 #endif /* _FBXSDK_SCENE_ANIMATION_UTILITIES_H_ */