Game Engine Architecture

(Ben Green) #1

502 11. Animation Systems


11.3.2.1. Joint Scale
Some game engines assume that joints will never be scaled, in which case Sj
is simply omitt ed and assumed to be the identity matrix. Other engines make
the assumption that scale will be uniform if present, meaning it is the same in
all three dimensions. In this case, scale can be represented using a single scalar
value sj. Some engines even permit nonuniform scale, in which case scale can
be compactly represented by the three-element vector sj = [ sjx sjy sjz ]. The ele-
ments of the vector sj correspond to the three diagonal elements of the 3 × 3
scaling matrix Sj , so it is not really a vector per se. Game engines almost never
permit shear, so Sj is almost never represented by a full 3 × 3 scale/shear ma-
trix, although it certainly could be.
There are a number of benefi ts to omitt ing or constraining scale in a pose
or animation. Clearly using a lower-dimensional scale representation can save
memory. (Uniform scale requires a single fl oating-point scalar per joint per
animation frame, while nonuniform scale requires three fl oats, and a full 3 × 3
scale-shear matrix requires nine.) Restricting our engine to uniform scale has
the added benefi t of ensuring that the bounding sphere of a joint will never
be transformed into an ellipsoid, as it could be when scaled in a nonuniform
manner. This greatly simplifi es the mathematics of frustum and collision tests
in engines that perform such tests on a per-joint basis.
11.3.2.2. Representing a Joint Pose in Memory
As we mentioned above, joint poses are usually stored in SQT format. In C++
such a data structure might look like this, where Q is fi rst to ensure proper
alignment and optimal structure packing. (Can you see why?)

struct JointPose
{
Quaternion m_rot; // Q
Vector3 m_trans; // T
F32 m_scale; // S (uniform scale only)
};

If nonuniform scale is permitt ed, we might defi ne a joint pose like this
instead:

struct JointPose
{
Quaternion m_rot; // Q
Vector3 m_trans; // T
Vector3 m_scale; // S
U8 padding[8];
};
Free download pdf