Transformation Data
 
 
 

Translation, Rotation and Scaling Vectors

The default translation, rotation, and scaling (default TRS properties) of a node are accessed using the KFbxNode::LclTranslation, KFbxNode::LclRotation, and KFbxNode::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 KFbxTypedPropertyAll 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:

Global and Local Transformation Matrices

A node's global and local tranformation matrices can be respectively obtained by calling KFbxNode::EvaluateGlobalTransform() and KFbxNode::EvaluateLocalTransform():

// Get the node's default global transformation matrix.
KFbxXMatrix& lGlobalTransform = lNode->EvaluateGlobalTransform();

// Get the node's default local transformation matrix.
KFbxXMatrix& lLocalTransform = lNode->EvaluateLocalTransform();

These member functions are equivalent to using the KFbxScene's animation evaluator KFbxAnimEvaluator::GetNodeGlobalTransform() and KFbxAnimEvaluator::GetNodeLocalTransform() functions:

// Get the scene's animation evaluator.
KFbxAnimEvaluator* lEvaluator = lScene->getEvaluator();
 
// Get the node's default global transformation matrix.
KFbxXMatrix& lGlobalTransform = lEvaluator->GetNodeGlobalTransform(lNode);

// Get the node's default local transformation matrix.
KFbxXMatrix& lLocalTransform = lEvaluator->GetNodeLocalTransform(lNode);

An animated node's transformation matrix can be obtained for a specific point in time by passing a KTime object.

KTime lTime;

// Set the time at two seconds.
lTime.SetSecondDouble((float) 2);

// Get the node's global transformation matrix at 2 seconds.
KFbxXMatrix& lGlobalTransform = lNode->EvaluateGlobalTransform(lTime);
NoteA node's global transformation matrix of cannot be explicitly set in the FBX SDK.

Baking Transform Components Into the Standard TRS Transforms

The KFbxNode::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 (KFbxNode).
// 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.
{
    KFbxVector4 lZero(0,0,0);

    // Activate pivot converting
    pNode->SetPivotState(KFbxNode::eSOURCE_SET, KFbxNode::ePIVOT_STATE_ACTIVE);
    pNode->SetPivotState(KFbxNode::eDESTINATION_SET, KFbxNode::ePIVOT_STATE_ACTIVE);

    // We want to set all these to 0 and bake them into the transforms.
    pNode->SetPostRotation(KFbxNode::eDESTINATION_SET, lZero);
    pNode->SetPreRotation(KFbxNode::eDESTINATION_SET, lZero);
    pNode->SetRotationOffset(KFbxNode::eDESTINATION_SET, lZero);
    pNode->SetScalingOffset(KFbxNode::eDESTINATION_SET, lZero);
    pNode->SetRotationPivot(KFbxNode::eDESTINATION_SET, lZero);
    pNode->SetScalingPivot(KFbxNode::eDESTINATION_SET, lZero);

    // This is to import in a system that supports rotation order.
    // If rotation order is not supported, do this instead:
    // pNode->SetRotationOrder(KFbxNode::eDESTINATION_SET , KFbxNode::eEULER_XYZ);
    ERotationOrder lRotationOrder;
    pNode->GetRotationOrder(KFbxNode::eSOURCE_SET , lRotationOrder);
    pNode->SetRotationOrder(KFbxNode::eDESTINATION_SET , 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(KFbxNode::eDESTINATION_SET, pNode->GetGeometricTranslation(KFbxNode::eSOURCE_SET));
    pNode->SetGeometricRotation(KFbxNode::eDESTINATION_SET, pNode->GetGeometricRotation(KFbxNode::eSOURCE_SET));
    pNode->SetGeometricScaling(KFbxNode::eDESTINATION_SET, pNode->GetGeometricScaling(KFbxNode::eSOURCE_SET));

    // Idem for quaternions.
    pNode->SetUseQuaternionForInterpolation(KFbxNode::eDESTINATION_SET, pNode->GetUseQuaternionForInterpolation(KFbxNode::eSOURCE_SET));
}

// When the setup is done, call ConvertPivotAnimationRecursive to the scene’s root node.
// Sampling rate e.g. 30.0.
mScene->GetRootNode()->ConvertPivotAnimationRecursive(KFbxNode::eDESTINATION_SET, lSamplingRate );
NoteTo avoid re-computing the pivots matrices and updating the animation curves each time one of the parameters is changed, the FBX SDK only applies the new settings when an explicit call is made to ResetPivotSetAndConvertAnimation() or ConvertPivotAnimationRecursive().