The default translation, rotation, and scaling (default TRS properties) of a node are accessed using the FbxNode::LclTranslation, FbxNode::LclRotation, and FbxNode::LclScaling properties:
// Get the node’s default TRS properties FbxDouble3 lTranslation = lNode->LclTranslation.Get(); FbxDouble3 lRotation = lNode->LclRotation.Get(); FbxDouble3 lScaling = lNode->LclScaling.Get();
The FbxTypedPropertyAll three member functions return vectors of type FbxDouble3. The value of each vector is a triplet of X, Y, and Z coordinates. The value of one of these vectors is an offset from the corresponding default TRS property vector for the parent node. A node’s default TRS properties are therefore local to the parent node.
The actual TRS properties for the node at a given point in time depend on:
A node's global and local transformation matrices can be respectively obtained by calling FbxNode::EvaluateGlobalTransform() and FbxNode::EvaluateLocalTransform():
// Get the node's default global transformation matrix. FbxAMatrix& lGlobalTransform = lNode->EvaluateGlobalTransform(); // Get the node's default local transformation matrix. FbxAMatrix& lLocalTransform = lNode->EvaluateLocalTransform();
These member functions are equivalent to using the FbxScene's animation evaluator FbxAnimEvaluator::GetNodeGlobalTransform() and FbxAnimEvaluator::GetNodeLocalTransform() functions:
// Get the scene's animation evaluator. FbxAnimEvaluator* lEvaluator = lScene->getEvaluator(); // Get the node's default global transformation matrix. FbxAMatrix& lGlobalTransform = lEvaluator->GetNodeGlobalTransform(lNode); // Get the node's default local transformation matrix. FbxAMatrix& lLocalTransform = lEvaluator->GetNodeLocalTransform(lNode);
An animated node's transformation matrix can be obtained for a specific point in time by passing a FbxTime object.
FbxTime lTime; // Set the time at two seconds. lTime.SetSecondDouble((float) 2); // Get the node's global transformation matrix at 2 seconds. FbxAMatrix& lGlobalTransform = lNode->EvaluateGlobalTransform(lTime);
The FbxNode geometric transformation properties (FbxNode::GeometricTranslation, FbxNode::GeometricRotation, and FbxNode::GeometricScaling) describe how a FbxNodeAttribute is offset from the FbxNode's local frame of reference. These geometric transforms are applied to the FbxNodeAttribute after the FbxNode's local transforms are computed, and are not inherited across the node hierarchy.
The FbxNode::ConvertPivotAnimationRecursive() function lets you bake transform components: pre- and post-rotation, rotation and scale pivots and offsets - inside the standard transforms - Translation, Rotation, Scaling. Here is a code snippet.
// Do this setup for each node (FbxNode). // We set up what we want to bake via ConvertPivotAnimationRecursive. // When the destination is set to 0, baking will occur. // When the destination value is set to the source’s value, the source values will be retained and not baked. { FbxVector4 lZero(0,0,0); // Activate pivot converting pNode->SetPivotState(FbxNode::eSourcePivot, FbxNode::ePivotActive); pNode->SetPivotState(FbxNode::eDestinationPivot, FbxNode::ePivotActive); // We want to set all these to 0 and bake them into the transforms. pNode->SetPostRotation(FbxNode::eDestinationPivot, lZero); pNode->SetPreRotation(FbxNode::eDestinationPivot, lZero); pNode->SetRotationOffset(FbxNode::eDestinationPivot, lZero); pNode->SetScalingOffset(FbxNode::eDestinationPivot, lZero); pNode->SetRotationPivot(FbxNode::eDestinationPivot, lZero); pNode->SetScalingPivot(FbxNode::eDestinationPivot, lZero); // This is to import in a system that supports rotation order. // If rotation order is not supported, do this instead: // pNode->SetRotationOrder(FbxNode::eDestinationPivot, FbxNode::eEulerXYZ); ERotationOrder lRotationOrder; pNode->GetRotationOrder(FbxNode::eSourcePivot, lRotationOrder); pNode->SetRotationOrder(FbxNode::eDestinationPivot, lRotationOrder); // Similarly, this is the case where geometric transforms are supported by the system. // If geometric transforms are not supported, set them to zero instead of // the source’s geometric transforms. // Geometric transform = local transform, not inherited by children. pNode->SetGeometricTranslation(FbxNode::eDestinationPivot, pNode->GetGeometricTranslation(FbxNode::eSourcePivot)); pNode->SetGeometricRotation(FbxNode::eDestinationPivot, pNode->GetGeometricRotation(FbxNode::eSourcePivot)); pNode->SetGeometricScaling(FbxNode::eDestinationPivot, pNode->GetGeometricScaling(FbxNode::eSourcePivot)); // Idem for quaternions. pNode->SetUseQuaternionForInterpolation(FbxNode::eDestinationPivot, pNode->GetUseQuaternionForInterpolation(FbxNode::eSourcePivot)); } // When the setup is done, call ConvertPivotAnimationRecursive to the scene’s root node. // Sampling rate e.g. 30.0. mScene->GetRootNode()->ConvertPivotAnimationRecursive(FbxNode::eDestinationPivot, lSamplingRate );