FBX C++ API Reference
fbxanimcurvenode.h
Go to the documentation of this file.
1 /****************************************************************************************
2 
3  Copyright (C) 2015 Autodesk, Inc.
4  All rights reserved.
5 
6  Use of this software is subject to the terms of the Autodesk license agreement
7  provided at the time of installation or download, or which otherwise accompanies
8  this software in either electronic or hard copy form.
9 
10 ****************************************************************************************/
11 
13 #ifndef _FBXSDK_SCENE_ANIMATION_CURVE_NODE_H_
14 #define _FBXSDK_SCENE_ANIMATION_CURVE_NODE_H_
15 
16 #include <fbxsdk/fbxsdk_def.h>
17 
18 #include <fbxsdk/core/fbxobject.h>
19 
20 #include <fbxsdk/fbxsdk_nsbegin.h>
21 
22 //Standard curve node names
23 #define FBXSDK_CURVENODE_TRANSFORM "Transform"
24 #define FBXSDK_CURVENODE_TRANSLATION "T"
25 #define FBXSDK_CURVENODE_ROTATION "R"
26 #define FBXSDK_CURVENODE_SCALING "S"
27 #define FBXSDK_CURVENODE_COMPONENT_X "X"
28 #define FBXSDK_CURVENODE_COMPONENT_Y "Y"
29 #define FBXSDK_CURVENODE_COMPONENT_Z "Z"
30 #define FBXSDK_CURVENODE_COLOR "Color"
31 #define FBXSDK_CURVENODE_COLOR_RED FBXSDK_CURVENODE_COMPONENT_X
32 #define FBXSDK_CURVENODE_COLOR_GREEN FBXSDK_CURVENODE_COMPONENT_Y
33 #define FBXSDK_CURVENODE_COLOR_BLUE FBXSDK_CURVENODE_COMPONENT_Z
34 
35 class FbxAnimStack;
36 class FbxAnimCurve;
37 class FbxMultiMap;
38 class KFCurveNode;
39 
56 {
58 
59 public:
73  bool IsAnimated(bool pRecurse=false) const;
74 
84  bool GetAnimationInterval(FbxTimeSpan& pTimeInterval) const;
85 
91  bool IsComposite() const;
92 
98  FbxAnimCurveNode* Find(const char* pName);
99 
110  static FbxAnimCurveNode* CreateTypedCurveNode(FbxProperty& pProperty, FbxScene* pScene);
111 
116  unsigned int GetChannelsCount() const;
117 
122  int GetChannelIndex(const char* pChannelName) const;
123 
128  FbxString GetChannelName(int pChannelId) const;
129 
135  void ResetChannels();
136 
143  template <class T> bool AddChannel(const char* pChnlName, T const &pValue)
144  {
145  if (!pChnlName || strlen(pChnlName)==0) return false;
146  FbxProperty c = GetChannel(pChnlName);
147  if (c.IsValid())
148  {
149  return false;
150  }
151 
152  mChannels.BeginCreateOrFindProperty();
154  c = FbxProperty::Create(mChannels, dt, pChnlName);
155  c.Set(pValue);
156  mChannels.EndCreateOrFindProperty();
157  return true;
158  }
159 
164  template <class T> void SetChannelValue(const char* pChnlName, T pValue)
165  {
166  FbxProperty c = GetChannel(pChnlName);
167  if( c.IsValid() ) c.Set(pValue);
168  }
169 
174  template <class T> void SetChannelValue(unsigned int pChnlId, T pValue)
175  {
176  FbxProperty c = GetChannel(pChnlId);
177  if( c.IsValid() ) c.Set(pValue);
178  }
179 
185  template <class T> T GetChannelValue(const char* pChnlName, T pInitVal)
186  {
187  T v = pInitVal;
188  FbxProperty c = GetChannel(pChnlName);
189  if( c.IsValid() ) v = c.Get<T>();
190  return v;
191  }
192 
198  template <class T> T GetChannelValue(unsigned int pChnlId, T pInitVal)
199  {
200  T v = pInitVal;
201  FbxProperty c = GetChannel(pChnlId);
202  if( c.IsValid() ) v = c.Get<T>();
203  return v;
204  }
206 
217  bool DisconnectFromChannel(FbxAnimCurve* pCurve, unsigned int pChnlId);
218 
226  bool ConnectToChannel(FbxAnimCurve* pCurve, const char* pChnl, bool pInFront = false);
227 
236  bool ConnectToChannel(FbxAnimCurve* pCurve, unsigned int pChnlId, bool pInFront = false);
237 
247  FbxAnimCurve* CreateCurve(const char* pCurveNodeName, const char* pChannel);
248 
258  FbxAnimCurve* CreateCurve(const char* pCurveNodeName, unsigned int pChannelId = 0);
259 
273  int GetCurveCount(unsigned int pChannelId, const char* pCurveNodeName = NULL);
274 
287  FbxAnimCurve* GetCurve(unsigned int pChannelId, unsigned int pId = 0, const char* pCurveNodeName = NULL);
288 
290 
291 /*****************************************************************************************************************************
292 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
293 *****************************************************************************************************************************/
294 #ifndef DOXYGEN_SHOULD_SKIP_THIS
295  virtual FbxObject& Copy(const FbxObject& pObject);
296 
297  static const char* CurveNodeNameFrom(const char* pName);
298  static bool EvaluateChannels(FbxAnimCurveNode* pCurveNode, double* pData, unsigned int pCount, FbxTime pTime);
299 
300  void ReleaseKFCurveNode();
301  void SyncChannelsWithKFCurve();
302 
303  inline bool UseQuaternionInterpolation() {return mQuaternionInterpolation != 0;};
304  bool SetQuaternionInterpolation(unsigned short pVal);
305  unsigned short GetQuaternionInterpolation() { return mQuaternionInterpolation; };
306  void SetKFCurveNodeLayerType(FbxProperty& pProp);
307  KFCurveNode* GetKFCurveNode(bool pNoCreate=false);
308 
309 private:
311  friend class FbxAnimEvalClassic;
312  void Evaluate(double* pData, FbxTime pTime);
313 
314 protected:
315  virtual void Construct(const FbxObject* pFrom);
316  virtual void Destruct(bool pRecursive);
317  virtual void ConstructProperties(bool pForceSet);
318  virtual bool ConnectNotify(const FbxConnectEvent& pEvent);
319 
320  FbxAnimCurveNode* Find(FbxAnimCurveNode* pRoot, const FbxString& pName);
321 
322 private:
323  FbxProperty GetChannel(const char* pChnl);
324  FbxProperty GetChannel(unsigned int pChnlId);
325 
326  friend void CollectAnimFromCurveNode(void **lSrc, void *fcn, unsigned int nbCrvs, FbxAnimCurveNode *cn, FbxMultiMap* pNickToAnimCurveTimeWarpsSet, FbxMultiMap& pNickToKFCurveNodeWarpSet);
327 
328  unsigned char mNonRemovableChannels;
329  FbxProperty mChannels;
330  FbxProperty* mCurrentlyProcessed;
331  KFCurveNode* mFCurveNode;
332  bool* mOwnedKFCurve;
333  int mKFCurveNodeLayerType;
334  unsigned short mQuaternionInterpolation;
335  int* mDirectIndexes;
336  int mDirectIndexesSize;
337 
338  FbxAnimCurve* GetCurve(unsigned int pChannelId, unsigned int pId, FbxAnimCurveNode* pCurveNode);
339  bool ConnectToChannel(FbxProperty& p, FbxAnimCurve* pCurve, bool pInFront);
340  void ResetKFCurveNode();
341  void SyncKFCurveValue(FbxAnimCurve* pCurve, double pVal);
342  void ReleaseOwnershipOfKFCurve(int pIndex);
343 
344  template <class T> FbxAnimCurve* CreateCurveGeneral(const char* pCurveNodeName, T pChannel);
345 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
346 };
347 
350 
351 #include <fbxsdk/fbxsdk_nsend.h>
352 
353 #endif // FBXFILESDK_KFBXPLUGINS_KFBXANIMCURVENODE_H
354 
#define FBXSDK_OBJECT_DECLARE(Class, Parent)
Macro used to declare a new class derived from FbxObject.
Definition: fbxobject.h:61
An evaluator implementation that behaves like the original FBX SDK (2010 and previous) evaluation sys...
FBX SDK environment definition.
The Animation stack is a collection of animation layers.
Definition: fbxanimstack.h:37
This class is an composite of animation curves and is called as animation curve node.
#define NULL
Definition: fbxarch.h:210
virtual FbxObject & Copy(const FbxObject &pObject)
Copy an object content into this object.
Utility class to manipulate strings.
Definition: fbxstring.h:66
T GetChannelValue(const char *pChnlName, T pInitVal)
Get the default value of the channel.
FBX SDK data type class.
Definition: fbxdatatypes.h:26
const FbxDataType & FbxGetDataTypeFromEnum(const EFbxType pType)
Retrieve data type from type enumeration index.
bool AddChannel(const char *pChnlName, T const &pValue)
Adds the specified channel property.
static FbxProperty Create(const FbxProperty &pCompoundProperty, const FbxDataType &pDataType, const char *pName, const char *pLabel="", bool pCheckForDup=true, bool *pWasFound=((void *) 0))
Creates a runtime property on the specified property.
void SetChannelValue(unsigned int pChnlId, T pValue)
Set the default value of the channel.
Class to encapsulate time units.
Definition: fbxtime.h:44
The base class of most FBX objects.
Definition: fbxobject.h:157
This class contains the description of a 3D scene.
Definition: fbxscene.h:61
EFbxType FbxTypeOf(const FbxChar &)
virtual void Construct(const FbxObject *pFrom)
Optional constructor override, automatically called by default constructor.
void GetAllAnimCurves(FbxAnimStack *pAnimStack, FbxArray< FbxAnimCurve *> &pCurves)
T Get() const
Gets the value of the property.
Definition: fbxproperty.h:289
Class to hold user properties.
Definition: fbxproperty.h:37
bool Set(const T &pValue)
Sets the value of the property.
Definition: fbxproperty.h:295
An animation curve, defined by a collection of keys (FbxAnimCurveKey), and indicating how a value cha...
Definition: fbxanimcurve.h:779
#define FBXSDK_DLL
Definition: fbxarch.h:173
void SetChannelValue(const char *pChnlName, T pValue)
Set the default value of the channel.
Class to encapsulate time intervals.
Definition: fbxtime.h:508
bool IsValid() const
Judges the property&#39;s validity.
virtual void Destruct(bool pRecursive)
Optional destructor override, automatically called by default destructor.
Class to manipulate a map that can contain multiple times the same key.
Definition: fbxmultimap.h:22
virtual void ConstructProperties(bool pForceSet)
Optional property constructor override, automatically called by default constructor.
T GetChannelValue(unsigned int pChnlId, T pInitVal)
Get the default value of the channel.
Class for array of basic elements such as pointers and basic types.
Definition: fbxarray.h:23