00001
00004 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXANIMCURVENODE_H
00005 #define FBXFILESDK_KFBXPLUGINS_KFBXANIMCURVENODE_H
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
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
00275
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
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