kfbxanimcurvenode.h

Go to the documentation of this file.
00001 /****************************************************************************************
00002 
00003 Copyright (C) 2011 Autodesk, Inc.
00004 All rights reserved.
00005 
00006 This computer source code and related instructions and comments are the unpublished
00007 confidential and proprietary information of Autodesk, Inc. and are protected under
00008 applicable copyright and trade secret law.  They may not be disclosed to, copied or
00009 used by any third party without the prior written consent of Autodesk, Inc.
00010 
00011 ****************************************************************************************/
00012 
00016 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXANIMCURVENODE_H
00017 #define FBXFILESDK_KFBXPLUGINS_KFBXANIMCURVENODE_H
00018 
00019 #include <fbxfilesdk/fbxfilesdk_def.h>
00020 
00021 #include <fbxfilesdk/kfbxplugins/kfbxobject.h>
00022 
00023 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00024 class KFbxAnimStack;
00025 class KFbxAnimCurve;
00026 class KSet;
00027 
00039 class KFBX_DLL KFbxAnimCurveNode : public KFbxObject
00040 {
00041     KFBXOBJECT_DECLARE(KFbxAnimCurveNode, KFbxObject);
00042 
00043 public:
00054         bool IsAnimated(bool pRecurse=false) const;
00055 
00064         K_DEPRECATED bool GetAnimationInterval(KTime& pStart, KTime& pStop) const;
00065 
00072         bool GetAnimationInterval(KTimeSpan& pTimeInterval) const;
00073 
00079         bool IsComposite() const;
00080 
00086         KFbxAnimCurveNode* Find(const char* pName);
00087 
00098         static KFbxAnimCurveNode* CreateTypedCurveNode(KFbxProperty& pProperty, KFbxScene* pScene);
00099 
00104         unsigned int GetChannelsCount() const;
00105 
00110         int GetChannelIndex(const char* pChannelName) const;
00111 
00116         KString GetChannelName(int pChannelId) const;
00117 
00123         void ResetChannels();
00124 
00131         template <class T> bool AddChannel(const char* pChnlName, T const &pValue)
00132         {
00133             if (!pChnlName || strlen(pChnlName)==0) return false;
00134             KFbxProperty c = GetChannel(pChnlName);
00135             if (c.IsValid()) 
00136             {
00137                 return false;
00138             }
00139 
00140             mChannels.BeginCreateOrFindProperty();
00141             KFbxDataType dt = GetFbxDataType(FbxTypeOf(pValue));
00142             c = KFbxProperty::Create(mChannels, dt, pChnlName);
00143             KFbxSet<T>(c, pValue);
00144             mChannels.EndCreateOrFindProperty();
00145             return true;
00146         }
00147 
00152         template <class T> void SetChannelValue(const char* pChnlName, T pValue)
00153         {
00154             KFbxProperty c = GetChannel(pChnlName);
00155             if (c.IsValid()) KFbxSet<T>(c, pValue);
00156         }
00157 
00162         template <class T> void SetChannelValue(unsigned int pChnlId, T pValue)
00163         {
00164             KFbxProperty c = GetChannel(pChnlId);
00165             if (c.IsValid()) KFbxSet<T>(c, pValue);
00166         }
00167 
00173         template <class T> T GetChannelValue(const char* pChnlName, T pInitVal)
00174         {
00175             T v = pInitVal;
00176             KFbxProperty c = GetChannel(pChnlName);
00177             if (c.IsValid()) KFbxGet<T>(c, v);
00178             return v;
00179         }
00180 
00186         template <class T> T GetChannelValue(unsigned int pChnlId, T pInitVal)
00187         {
00188             T v = pInitVal;
00189             KFbxProperty c = GetChannel(pChnlId);
00190             if (c.IsValid()) KFbxGet<T>(c, v);
00191             return v;
00192         }
00194 
00205         bool DisconnectFromChannel(KFbxAnimCurve* pCurve, unsigned int pChnlId);
00206 
00214         bool ConnectToChannel(KFbxAnimCurve* pCurve, const char* pChnl, bool pInFront = false);
00215 
00224         bool ConnectToChannel(KFbxAnimCurve* pCurve, unsigned int pChnlId, bool pInFront = false);
00225 
00235         KFbxAnimCurve* CreateCurve(const char* pCurveNodeName, const char* pChannel);
00236 
00246         KFbxAnimCurve* CreateCurve(const char* pCurveNodeName, unsigned int pChannelId = 0);
00247         
00261         int GetCurveCount(unsigned int pChannelId, const char* pCurveNodeName = NULL);
00262 
00275         KFbxAnimCurve* GetCurve(unsigned int pChannelId, unsigned int pId = 0, const char* pCurveNodeName = NULL);
00276 
00278 
00279 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00280 
00281     //  WARNING!
00282     //  Anything beyond these lines may not be documented accurately and is 
00283     //  subject to change without notice.
00285 
00286     virtual KFbxObject& Copy(const KFbxObject& pObject);
00287 
00288     void Evaluate(double* pData, KTime pTime);
00289 
00295         
00305     KFCurveNode* GetKFCurveNode(bool pNoCreate=false);
00306 
00311     void ReleaseKFCurveNode();
00312 
00314     void SyncChannelsWithKFCurve();
00315 
00316     inline bool UseQuaternionInterpolation() {return mQuaternionInterpolation != 0;}; 
00317 
00319     bool SetQuaternionInterpolation(unsigned short pVal); 
00320     unsigned short GetQuaternionInterpolation() { return mQuaternionInterpolation; };
00321 
00322     // sync the KFCurveNodeLayerType based on the property Datatype (see the source code for details)
00323     void SetKFCurveNodeLayerType(KFbxProperty& pProp);
00324 
00325     static const char* CurveNodeNameFrom(const char* pName);
00327 
00328 private:
00335     KFbxProperty GetChannel(const char* pChnl);
00336 
00343     KFbxProperty GetChannel(unsigned int pChnlId);
00344 
00345 protected:
00346     KFbxAnimCurveNode(KFbxSdkManager& pManager, char const* pName);
00347     KFbxAnimCurveNode* Find(KFbxAnimCurveNode* pRoot, const KString& pName);
00348     virtual bool ConstructProperties( bool pForceSet );
00349     virtual void Destruct(bool pRecursive, bool pDependents);
00350 
00351 private:
00352     friend class KFbxObject;
00353     friend void CollectAnimFromCurveNode(KFCurve **lSrc, KFCurveNode *fcn, unsigned int nbCrvs, KFbxAnimCurveNode *cn, KSet* pNickToAnimCurveTimeWarpsSet, KSet& pNickToKFCurveNodeWarpSet);
00354     unsigned char   mNonRemovableChannels;
00355     KFbxProperty    mChannels;
00356     KFbxProperty*   mCurrentlyProcessed;
00357     KFCurveNode*    mFCurveNode;
00358     bool*           mOwnedKFCurve;
00359     int             mKFCurveNodeLayerType;
00360     unsigned short  mQuaternionInterpolation;
00361     int*            mDirectIndexes;
00362     int             mDirectIndexesSize;
00363 
00364     KFbxAnimCurve* GetCurve(unsigned int pChannelId, unsigned int pId, KFbxAnimCurveNode* pCurveNode);
00365     bool ConnectToChannel(KFbxProperty& p, KFbxAnimCurve* pCurve, bool pInFront);
00366     void ResetKFCurveNode();
00367     void SyncKFCurveValue(KFbxAnimCurve* pCurve, double pVal);
00368     void ReleaseOwnershipOfKFCurve(int pIndex);
00369 
00370     template <class T> KFbxAnimCurve* CreateCurveGeneral(const char* pCurveNodeName, T pChannel);
00371 
00372 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00373 };
00374 typedef KFbxAnimCurveNode* HKKFbxAnimCurveNode;
00375 
00376 KFBX_DLL void GetAllAnimCurves(KFbxAnimStack* pAnimStack, KArrayTemplate<KFbxAnimCurve*>& pCurves);
00377 KFBX_DLL void GetAllAnimCurves(KFbxObject* pObj, KFbxAnimStack* pAnimStack, KArrayTemplate<KFbxAnimCurve*>& pCurves);
00378 
00379 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00380 
00381 #endif // FBXFILESDK_KFBXPLUGINS_KFBXANIMCURVENODE_H
00382