You can extract and query the animation data from a scene (FBX file) without loading the entire FBX file.
A scene (FbxScene) can contain one or more animation stacks (FbxAnimStack). The animation stack is the highest-level container for the animation data and contains one or more animation layers (FbxAnimLayer). An animation layer contains one or more animation curve nodes (FbxAnimCurveNode). An animation curve node is the connection point between the animation curves (FbxAnimCurve) and the FBX properties (FbxProperty) of a FBX object (FbxObject).
Perform the following steps to extract the animation data from a scene:
int numStacks = pScene->GetSrcObjectCount(FBX_TYPE(FbxAnimStack)); i++)
FbxAnimStack* pAnimStack = FbxCast<FbxAnimStack>(pScene->GetSrcObject(FBX_TYPE(FbxAnimStack), n)
int numAnimLayers = pAnimStack->GetMemberCount(FBX_TYPE(FbxAnimLayer));
FbxAnimLayer* lAnimLayer = lAnimStack->GetMember(FBX_TYPE(FbxAnimLayer), n);
After retrieving an animation layer, you can access the animation curves for the properties of nodes and node attribute.
FbxAnimCurve* lAnimCurve = lNode->LclTranslation.GetCurve(lAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
FbxNodeAttribute* lNodeAttribute = lNode->GetNodeAttribute(); FbxAnimCurve* lAnimCurve = lNodeAttribute->Color.GetCurve<FbxAnimCurve>(pAnimLayer, FBXSDK_CURVENODE_COLOR_RED);
You can also use the animation curve nodes to access the animation data for the properties. The following steps show how to access the animation curves for a specific property on the first (0th) channel.
if (lProperty.IsValid) ...
FbxAnimCurveNode* lCurveNode = lProperty.GetCurveNode(pAnimLayer);
If the property is not animated the curve node is NULL.
if (lCurveNode != NULL) ...
for( int c = 0; c < lCurveNode->GetCurveCount(0U); c++ ) { FbxAnimCurve* lAnimCurve = lCurveNode->GetCurve(0U, c); if (lAnimCurve != NULL) { // ... } }
See the FbxAnimCurveNode class reference for more information on animation curve nodes and channels.
For a more detailed example of importing animation data using the FBX SDK, see the example ImportScene/DisplayAnimation.cxx.