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