Matrix Transformation Order

 
 
 

Matrix Transformation Order

In MotionBuilder, the global translation, rotation, and scale matrices of a model are all computed separately. These matrix computations follow a particular order, as illustrated in the sections below. We use the M suffix to denote matrices, and the V suffix to identify vectors.

Global Rotation Matrix

We compute the local (LocalRotationM) and global (GlobalRotationM) rotation matrices as follows. Note that the matrix operations are applied from right to left.

(1) RotationDoFM = KRotationM · JRotationM · IRotationM

The IRotationM, JRotationM, and KRotationM matrices describe the amount of rotation around each local axis, depending on the model's rotation order (FBModel.RotationOrder). For example, if the model's rotation order is set to Euler ZYX (FBModelRotationOrder.kFBEulerZYX):

NoteThe "I", "J", "K" prefixes here are not related to quaternion rotations.
(2) LocalRotationM = PreRotationM · RotationDoFM · PostRotationM-1

Where PostRotationM-1 denotes the inverse of the PostRotationM matrix.

TipPost rotations are useful when you want to create a skeleton whose T-Pose corresponds to bones with a 0 local rotation value along each axis. If you change the pre/post rotations, this will affect the model's children. To only affect the model's geometry, you can change the FBModel.GeometricTranslation, FBModel.GeometricRotation and FBModel.GeometricScaling transformations.
(3) GlobalRotationM = ParentGlobalRotationM · LocalRotationM

Where the ParentGlobalRotationM matrix is the parent FBModel's GlobalRotationM matrix. The resulting local rotation matrix (LocalRotationM) is used later in the global scale and translation matrix computations below.

Global Scale Matrix

The computation of an FBModel's global scale matrix (GlobalScaleM) is computed differently depending on the scale inherit type of its parent.

Parent's Scaling Inherit Type Description
Local (RrSs) Activates local scaling mode. If you scale a parent object on its X-, Y-, or Z-axis, child objects scale on their local X-, Y-, or Z-axis. The child objects also translate to keep proportional distance from the parent. You can still scale the child object without affecting the parent.
Parent (RSrs) Activates parent scaling mode. If you scale a parent object on one axis, Child objects deform to maintain their volume while stretching to scale on the same axis. For example, you can use this option if you have a group of models and you want them all to scale down on the same axis and appear squashed.
Scale Compensate In this mode, Child objects do not inherit scaling from parent objects at all. When a parent object is scaled, the child does not scale, but translates in order to keep proportional distance between models.

Local (RrSs) Scaling Inherit Type

The result of this computation is a vector (GlobalScaleV), so that no shear can be induced.

(4a) GlobalScaleV = ParentGlobalScaleV · LocalScaleV

Parent (RSrs) Scaling Inherit Type

This computation relies on the local rotation matrix (LocalRotationM) defined above.

(4b) GlobalScaleM = LocalRotationM-1 · ParentGlobalScaleM · LocalRotationM · LocalScaleM

Scale Compensate Inherit Type

(4c) GlobalScaleM = LocalRotationM-1 · ParentGlobalScaleM · ParentLocalScaleM-1 · LocalRotationM · LocalScaleM

Global Translation Matrix

The global translation vector (and matrix) of an FBModel is computed according to the following steps. It makes use of the LocalScaleM

(5) ScalePivotTranslationV = (I - LocalScaleM) · ScalePivotV + ScalePivotOffsetV
    Where I is the identity matrix.

(6) ScaleAndRotatePivotTranslationV = (LocalRotationM · (ScalePivotTranslationV - RotationPivotV)) + RotationPivotV + RotationPivotOffsetV

(7) LocalTranslationV = TranslationDoFV + RotatePivotTranslationV

(8) GlobalTranslationV = ParentGlobalTransformationM · LocalTranslationV 

Global Transformation Matrix

The global transformation matrix of an FBModel makes use of the computed global translation, rotation and scaling matrices.

(9) GlobalTransformationMatrix = GlobalTranslationM · GlobalRotationM · GlobalScaleM