To render an animated scene (FbxScene
), you must evaluate the animated properties of objects (FbxObject
) in a scene at different points in time. For example, to display a moving race car that is represented by a mesh, you must animate the local translation property of the node whose node attribute is the mesh. See FbxNode::LclTranslation
.
Get an evaluator object from the scene object that contains the node.
// Let us assume that myScene is already created
FbxAnimEvaluator* mySceneEvaluator = MyScene->GetAnimationEvaluator();
Create a time object.
FbxTime myTime; // The time for each key in the animation curve(s)
myTime.SetSecondDouble(0.0); // Starting time
Create a node object.
// Create a node object
FbxNode* myMeshNode = FbxNode::Create (myScene, "");
// ... Code to connect myMeshNode to a mesh object
Get the global transformation matrix or local transformation matrix of the node at a specific time.
To get the global transformation matrix:
// Get a reference to node’s global transform.
FbxMatrix& GlobalMatrix = mySceneEvaluator->GetNodeGlobalTransform(myMeshNode, myTime);
To get the local transformation matrix:
// Get a reference to node’s local transform.
FbxMatrix& GlobalMatrix = mySceneEvaluator->GetNodeLocalTransform(myMeshNode, myTime);
Evaluate the camera’s position expressed as a vector at a specific time. Note A transformation matrix is not needed to evaluate a camera's position.
// Given a scene, we can create a camera
FbxCamera* myCamera = FbxCamera::Create (myScene, "");
// Store the value of the property in an animation curve node
FbxAnimCurveNode& myCameraPositionVector;
// Get and store the value of the camera's local translation
myCameraPositionVector = mySceneEvaluator->GetPropertyValue (myCamera->Position, myTime);
Evaluate a material property at a specific time.
FbxTime time;
time.SetSecondDouble(3.5);
FbxColor color = MyMaterial->GetDiffuseColor()->EvaluateValue(time);
See Animation/main.cxx
for an example that illustrates the use of animation stacks, animation layers, animation curve nodes, and animation curves.
In the code snippet above, the FbxAnimCurveNode
object is not used as a connection point between an animation curve and a FBX property. Instead, FbxAnimCurveNode
is used as a convenient place to store the vector of the property returned by the evaluator. The animatable properties of FBX objects come in many data types. Some data types are scalars, for example, FbxDouble1
, FbxInteger1
, and FbxBool1
. Other data types have triplet (X, Y, Z) values that are stored as vectors.
FbxNode::LclTranslation
is of type FbxDouble3
, which is a vector with three elements. FbxAnimCurveNode
is a container that can store the value of any FBX property irrespective of the data type. The member functions of FbxAnimCurveNode
enables you to access the value of each element in a vector, for example, to get the value of channel X, the value of channel Y, and the value of channel Z.
FbxNode::LclTranslation
FbxAnimCurveNode::GetChannelCount()
,FbxAnimCurveNode::GetChannelValue()
, and other related functionsfbxdatatypes.h
, for a full list of FBX data types