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 explained in the following sections. The M suffix is used to denote matrices, and the V suffix is used to identify vectors.

Global Rotation Matrix

The local (LocalRotationM) and global (GlobalRotationM) rotation matrices are calculated as follows. 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), the amount of rotation is as follows:

Note: The I, J, and K prefixes are not related to quaternion rotations.
(2) LocalRotationM = PreRotationM · RotationDoFM · PostRotationM-1

Where, PostRotationM denotes the inverse of the PostRotationM matrix.

Tip: Post 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, it affects 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 in the following global scale and translation matrix computations.

Global Scale Matrix

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

Parent's Scaling Inherit TypeDescription
Local (RrSs)Activates the local scaling mode. If you scale a parent object on its X, Y, or Z axis, the 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 the parent scaling mode. If you scale a parent object on one axis, the 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 CompensateIn this mode, the child objects do not inherit scaling from the parent objects at all. When a parent object is scaled, the child does not scale, but translates to keep the proportional distance between the models.

Local (RrSs) Scaling Inherit Type

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

(4a) GlobalScaleV = ParentGlobalScaleV · LocalScaleV

Parent (RSrs) Scaling Inherit Type

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

(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 as follows using 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 

Where,

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