kfbxanimcurvenode.h

Go to the documentation of this file.
00001 
00004 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXANIMCURVENODE_H
00005 #define FBXFILESDK_KFBXPLUGINS_KFBXANIMCURVENODE_H
00006 
00007 /**************************************************************************************
00008 
00009  Copyright (C) 2010 Autodesk, Inc. and/or its licensors.
00010  All Rights Reserved.
00011 
00012  The coded instructions, statements, computer programs, and/or related material 
00013  (collectively the "Data") in these files contain unpublished information 
00014  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00015  Canada and United States of America federal copyright law and by international 
00016  treaties. 
00017  
00018  The Data may not be disclosed or distributed to third parties, in whole or in
00019  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00020 
00021  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00022  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00023  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00024  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00025  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00026  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00027  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00028  
00029  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00030  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00031  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00032  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00033  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00034  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00035  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00036  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00037  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00038  OR DAMAGE. 
00039 
00040 **************************************************************************************/
00041 #include <fbxfilesdk/fbxfilesdk_def.h>
00042 
00043 #include <fbxfilesdk/kfbxplugins/kfbxobject.h>
00044 
00045 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00046 class KFbxAnimStack;
00047 class KFbxAnimCurve;
00048 static void CollectAnimFromCurveNode(KFCurve **lSrc, KFCurveNode *fcn, unsigned int nbCrvs, KFbxAnimCurveNode *cn);
00049 
00053 class KFBX_DLL KFbxAnimCurveNode : public KFbxObject
00054 {
00055     KFBXOBJECT_DECLARE(KFbxAnimCurveNode, KFbxObject);
00056 
00057 public:
00067         bool IsAnimated(bool pRecurse=false) const;
00068 
00077         bool GetAnimationInterval(KTime& pStart, KTime& pStop) const;
00078 
00084         bool IsComposite() const;
00085 
00091         KFbxAnimCurveNode* Find(const char* pName);
00092 
00103         static KFbxAnimCurveNode* CreateTypedCurveNode(KFbxProperty& pProperty, KFbxScene* pScene);
00104 
00108         unsigned int GetChannelsCount() const;
00109 
00114         int GetChannelIndex(const char* pChannelName) const;
00115 
00120         KString GetChannelName(int pChannelId) const;
00121 
00126         void ResetChannels();
00127 
00134         template <class T> bool AddChannel(const char* pChnlName, T const &pValue)
00135         {
00136             if (!pChnlName || strlen(pChnlName)==0) return false;
00137             KFbxProperty c = GetChannel(pChnlName);
00138             if (c.IsValid()) 
00139             {
00140                 return false;
00141             }
00142 
00143             mChannels.BeginCreateOrFindProperty();
00144             KFbxDataType dt = GetFbxDataType(FbxTypeOf(pValue));
00145             c = KFbxProperty::Create(mChannels, dt, pChnlName);
00146             KFbxSet<T>(c, pValue);
00147             mChannels.EndCreateOrFindProperty();
00148             return true;
00149         }
00150 
00155         template <class T> void SetChannelValue(const char* pChnlName, T pValue)
00156         {
00157             KFbxProperty c = GetChannel(pChnlName);
00158             if (c.IsValid()) KFbxSet<T>(c, pValue);
00159         }
00160 
00165         template <class T> void SetChannelValue(unsigned int pChnlId, T pValue)
00166         {
00167             KFbxProperty c = GetChannel(pChnlId);
00168             if (c.IsValid()) KFbxSet<T>(c, pValue);
00169         }
00170 
00176         template <class T> T GetChannelValue(const char* pChnlName, T pInitVal)
00177         {
00178             T v = pInitVal;
00179             KFbxProperty c = GetChannel(pChnlName);
00180             if (c.IsValid()) KFbxGet<T>(c, v);
00181             return v;
00182         }
00183 
00189         template <class T> T GetChannelValue(unsigned int pChnlId, T pInitVal)
00190         {
00191             T v = pInitVal;
00192             KFbxProperty c = GetChannel(pChnlId);
00193             if (c.IsValid()) KFbxGet<T>(c, v);
00194             return v;
00195         }
00197 
00208         bool DisconnectFromChannel(KFbxAnimCurve* pCurve, unsigned int pChnlId);
00209 
00217         bool ConnectToChannel(KFbxAnimCurve* pCurve, const char* pChnl, bool pInFront = false);
00218 
00227         bool ConnectToChannel(KFbxAnimCurve* pCurve, unsigned int pChnlId, bool pInFront = false);
00228 
00236         KFbxAnimCurve* CreateCurve(const char* pCurveNodeName, const char* pChannel);
00237 
00245         KFbxAnimCurve* CreateCurve(const char* pCurveNodeName, unsigned int pChannelId = 0);
00246         
00255         int GetCurveCount(unsigned int pChannelId, const char* pCurveNodeName = NULL);
00256 
00267         KFbxAnimCurve* GetCurve(unsigned int pChannelId, unsigned int pId = 0, const char* pCurveNodeName = NULL);
00268 
00270 
00271 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00273     //  WARNING!
00274     //  Anything beyond these lines may not be documented accurately and is 
00275     //  subject to change without notice.
00277 
00278     virtual KFbxObject& Copy(const KFbxObject& pObject);
00279 
00280     void Evaluate(double* pData, KTime pTime);
00281 
00287         
00297     KFCurveNode* GetKFCurveNode(bool pNoCreate=false);
00298 
00303     void ReleaseKFCurveNode();
00304 
00306     void SyncChannelsWithKFCurve();
00307 
00308     inline bool GetUseQuaternion() {return mUseQuaternion;}; 
00309     void SetUseQuaternion(bool pVal); 
00310 
00311     // sync the KFCurveNodeLayerType based on the property Datatype (see the source code for details)
00312     void SetKFCurveNodeLayerType(KFbxProperty& pProp);
00313 
00314     static const char* CurveNodeNameFrom(const char* pName);
00316 
00317 private:
00324     KFbxProperty GetChannel(const char* pChnl);
00325 
00332     KFbxProperty GetChannel(unsigned int pChnlId);
00333 
00334 protected:
00335     KFbxAnimCurveNode(KFbxSdkManager& pManager, char const* pName);
00336     KFbxAnimCurveNode* Find(KFbxAnimCurveNode* pRoot, const KString& pName);
00337     virtual bool ConstructProperties( bool pForceSet );
00338     virtual void Destruct(bool pRecursive, bool pDependents);
00339 
00340 private:
00341     friend class KFbxObject;
00342     friend void CollectAnimFromCurveNode(KFCurve **lSrc, KFCurveNode *fcn, unsigned int nbCrvs, KFbxAnimCurveNode *cn);
00343     unsigned char   mNonRemovableChannels;
00344     KFbxProperty    mChannels;
00345     KFbxProperty*   mCurrentlyProcessed;
00346     KFCurveNode*    mFCurveNode;
00347     bool*           mOwnedKFCurve;
00348     int             mKFCurveNodeLayerType;
00349     bool            mUseQuaternion;
00350     int*            mDirectIndexes;
00351     int             mDirectIndexesSize;
00352 
00353     KFbxAnimCurve* GetCurve(unsigned int pChannelId, unsigned int pId, KFbxAnimCurveNode* pCurveNode);
00354     bool ConnectToChannel(KFbxProperty& p, KFbxAnimCurve* pCurve, bool pInFront);
00355     void ResetKFCurveNode();
00356     void SyncKFCurveValue(KFbxAnimCurve* pCurve, double pVal);
00357     void ReleaseOwnershipOfKFCurve(int pIndex);
00358 
00359 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00360 };
00361 typedef KFbxAnimCurveNode* HKKFbxAnimCurveNode;
00362 
00363 KFBX_DLL void GetAllAnimCurves(KFbxAnimStack* pAnimStack, KArrayTemplate<KFbxAnimCurve*>& pCurves);
00364 KFBX_DLL void GetAllAnimCurves(KFbxObject* pObj, KFbxAnimStack* pAnimStack, KArrayTemplate<KFbxAnimCurve*>& pCurves);
00365 
00366 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00367 
00368 #endif // FBXFILESDK_KFBXPLUGINS_KFBXANIMCURVENODE_H
00369