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.
Perform the following steps to evaluate the animation in a scene:
// Let us assume that myScene is already created FbxAnimEvaluator* mySceneEvaluator = MyScene->GetEvaluator();
FbxTime myTime; // The time for each key in the animation curve(s) myTime.SetSecondDouble(0.0); // Starting time
// Create a node object FbxNode* myMeshNode = FbxNode::Create (myScene, ""); // ... Code to connect myMeshNode to a mesh object
// Get a reference to node’s global transform. FbxMatrix& GlobalMatrix = mySceneEvaluator->GetNodeGlobalTransform(myMeshNode, myTime);
// Get a reference to node’s local transform. FbxMatrix& GlobalMatrix = mySceneEvaluator->GetNodeLocalTransform(myMeshNode, myTime);
// 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);
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.