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.
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):
(2) LocalRotationM = PreRotationM · RotationDoFM · PostRotationM-1
Where PostRotationM-1 denotes the inverse of the PostRotationM matrix.
(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.
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. |
The result of this computation is a vector (GlobalScaleV), so that no shear can be induced.
(4a) GlobalScaleV = ParentGlobalScaleV · LocalScaleV
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
The global transformation matrix of an FBModel makes use of the computed global translation, rotation and scaling matrices.
(9) GlobalTransformationMatrix = GlobalTranslationM · GlobalRotationM · GlobalScaleM