fbxsdk/scene/animation/fbxanimcurvenode.h Source File
 
 
 
fbxsdk/scene/animation/fbxanimcurvenode.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_CURVE_NODE_H_
00014 #define _FBXSDK_SCENE_ANIMATION_CURVE_NODE_H_
00015 
00016 #include <fbxsdk/fbxsdk_def.h>
00017 
00018 #include <fbxsdk/core/fbxobject.h>
00019 
00020 #include <fbxsdk/fbxsdk_nsbegin.h>
00021 
00022 //Standard curve node names
00023 #define FBXSDK_CURVENODE_TRANSFORM              "Transform"
00024 #define FBXSDK_CURVENODE_TRANSLATION    "T"
00025 #define FBXSDK_CURVENODE_ROTATION               "R"
00026 #define FBXSDK_CURVENODE_SCALING                "S"
00027 #define FBXSDK_CURVENODE_COMPONENT_X    "X"
00028 #define FBXSDK_CURVENODE_COMPONENT_Y    "Y"
00029 #define FBXSDK_CURVENODE_COMPONENT_Z    "Z"
00030 #define FBXSDK_CURVENODE_COLOR                  "Color"
00031 #define FBXSDK_CURVENODE_COLOR_RED              FBXSDK_CURVENODE_COMPONENT_X
00032 #define FBXSDK_CURVENODE_COLOR_GREEN    FBXSDK_CURVENODE_COMPONENT_Y
00033 #define FBXSDK_CURVENODE_COLOR_BLUE             FBXSDK_CURVENODE_COMPONENT_Z
00034 
00035 class FbxAnimStack;
00036 class FbxAnimCurve;
00037 class FbxSet;
00038 class KFCurveNode;
00039 
00055 class FBXSDK_DLL FbxAnimCurveNode : public FbxObject
00056 {
00057     FBXSDK_OBJECT_DECLARE(FbxAnimCurveNode, FbxObject);
00058 
00059 public:
00073         bool IsAnimated(bool pRecurse=false) const;
00074 
00084         bool GetAnimationInterval(FbxTimeSpan& pTimeInterval) const;
00085 
00091         bool IsComposite() const;
00092 
00098         FbxAnimCurveNode* Find(const char* pName);
00099 
00110         static FbxAnimCurveNode* CreateTypedCurveNode(FbxProperty& pProperty, FbxScene* pScene);
00111 
00116         unsigned int GetChannelsCount() const;
00117 
00122         int GetChannelIndex(const char* pChannelName) const;
00123 
00128         FbxString GetChannelName(int pChannelId) const;
00129 
00135         void ResetChannels();
00136 
00143         template <class T> bool AddChannel(const char* pChnlName, T const &pValue)
00144         {
00145             if (!pChnlName || strlen(pChnlName)==0) return false;
00146             FbxProperty c = GetChannel(pChnlName);
00147             if (c.IsValid()) 
00148             {
00149                 return false;
00150             }
00151 
00152             mChannels.BeginCreateOrFindProperty();
00153             FbxDataType dt = FbxGetDataTypeFromEnum(FbxTypeOf(pValue));
00154             c = FbxProperty::Create(mChannels, dt, pChnlName);
00155             c.Set(pValue);
00156             mChannels.EndCreateOrFindProperty();
00157             return true;
00158         }
00159 
00164         template <class T> void SetChannelValue(const char* pChnlName, T pValue)
00165         {
00166             FbxProperty c = GetChannel(pChnlName);
00167             if( c.IsValid() ) c.Set(pValue);
00168         }
00169 
00174         template <class T> void SetChannelValue(unsigned int pChnlId, T pValue)
00175         {
00176             FbxProperty c = GetChannel(pChnlId);
00177             if( c.IsValid() ) c.Set(pValue);
00178         }
00179 
00185         template <class T> T GetChannelValue(const char* pChnlName, T pInitVal)
00186         {
00187             T v = pInitVal;
00188             FbxProperty c = GetChannel(pChnlName);
00189             if( c.IsValid() ) v = c.Get<T>();
00190             return v;
00191         }
00192 
00198         template <class T> T GetChannelValue(unsigned int pChnlId, T pInitVal)
00199         {
00200             T v = pInitVal;
00201             FbxProperty c = GetChannel(pChnlId);
00202             if( c.IsValid() ) v = c.Get<T>();
00203             return v;
00204         }
00206 
00217         bool DisconnectFromChannel(FbxAnimCurve* pCurve, unsigned int pChnlId);
00218 
00226         bool ConnectToChannel(FbxAnimCurve* pCurve, const char* pChnl, bool pInFront = false);
00227 
00236         bool ConnectToChannel(FbxAnimCurve* pCurve, unsigned int pChnlId, bool pInFront = false);
00237 
00247         FbxAnimCurve* CreateCurve(const char* pCurveNodeName, const char* pChannel);
00248 
00258         FbxAnimCurve* CreateCurve(const char* pCurveNodeName, unsigned int pChannelId = 0);
00259         
00273         int GetCurveCount(unsigned int pChannelId, const char* pCurveNodeName = NULL);
00274 
00287         FbxAnimCurve* GetCurve(unsigned int pChannelId, unsigned int pId = 0, const char* pCurveNodeName = NULL);
00288 
00290 
00291 /*****************************************************************************************************************************
00292 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
00293 *****************************************************************************************************************************/
00294 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00295         virtual FbxObject& Copy(const FbxObject& pObject);
00296 
00297     void Evaluate(double* pData, FbxTime pTime);
00298 
00299     KFCurveNode* GetKFCurveNode(bool pNoCreate=false);
00300     void ReleaseKFCurveNode();
00301     void SyncChannelsWithKFCurve();
00302 
00303     inline bool UseQuaternionInterpolation() {return mQuaternionInterpolation != 0;}; 
00304         bool SetQuaternionInterpolation(unsigned short pVal); 
00305     unsigned short GetQuaternionInterpolation() { return mQuaternionInterpolation; };
00306     void SetKFCurveNodeLayerType(FbxProperty& pProp);
00307 
00308     static const char* CurveNodeNameFrom(const char* pName);
00309 
00310 protected:
00311         virtual void Construct(const FbxAnimCurveNode* pFrom);
00312     virtual void Destruct(bool pRecursive);
00313     virtual void ConstructProperties(bool pForceSet);
00314 
00315     FbxAnimCurveNode* Find(FbxAnimCurveNode* pRoot, const FbxString& pName);
00316 
00317 private:
00318     FbxProperty GetChannel(const char* pChnl);
00319     FbxProperty GetChannel(unsigned int pChnlId);
00320 
00321         friend void CollectAnimFromCurveNode(void **lSrc, void *fcn, unsigned int nbCrvs, FbxAnimCurveNode *cn, FbxSet* pNickToAnimCurveTimeWarpsSet, FbxSet& pNickToKFCurveNodeWarpSet);
00322 
00323     unsigned char       mNonRemovableChannels;
00324     FbxProperty         mChannels;
00325     FbxProperty*        mCurrentlyProcessed;
00326     KFCurveNode*        mFCurveNode;
00327     bool*                       mOwnedKFCurve;
00328     int                         mKFCurveNodeLayerType;
00329     unsigned short  mQuaternionInterpolation;
00330         int*                    mDirectIndexes;
00331         int                             mDirectIndexesSize;
00332 
00333     FbxAnimCurve* GetCurve(unsigned int pChannelId, unsigned int pId, FbxAnimCurveNode* pCurveNode);
00334     bool ConnectToChannel(FbxProperty& p, FbxAnimCurve* pCurve, bool pInFront);
00335     void ResetKFCurveNode();
00336     void SyncKFCurveValue(FbxAnimCurve* pCurve, double pVal);
00337         void ReleaseOwnershipOfKFCurve(int pIndex);
00338 
00339         template <class T> FbxAnimCurve* CreateCurveGeneral(const char* pCurveNodeName, T pChannel);
00340 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
00341 };
00342 
00343 FBXSDK_DLL void GetAllAnimCurves(FbxAnimStack* pAnimStack, FbxArray<FbxAnimCurve*>& pCurves);
00344 FBXSDK_DLL void GetAllAnimCurves(FbxObject* pObj, FbxAnimStack* pAnimStack, FbxArray<FbxAnimCurve*>& pCurves);
00345 
00346 #include <fbxsdk/fbxsdk_nsend.h>
00347 
00348 #endif // FBXFILESDK_KFBXPLUGINS_KFBXANIMCURVENODE_H
00349