Game Engine Architecture

(Ben Green) #1

560 11. Animation Systems


AnimationState in its AnimationStateSet. A skeletal pose is extracted
from the animation clip corresponding to each state at the time index specifi ed
by that state’s local clock. For each joint in the skeleton, an N-point weighted
average is then calculated for the translation vectors, rotation quaternions,
and scales, yielding the fi nal skeletal pose.

Ogre and the Playback Rate
It is interesting to note that Ogre has no concept of a playback rate (R). If
it did, we would have expected to see a data member like this in the
Ogre::AnimationState class:
Real mPlaybackRate;
Of course, we can still make animations play more slowly or more quickly in
Ogre by simply scaling the amount of time we pass to the addTime() func-
tion, but unfortunately, Ogre does not support animation time scaling out of
the box.
11.10.2.2. Example: Granny
The Granny animation system, by Rad Game Tools (htt p://www.radgame-
tools.com/granny.html), provides a fl at, weighted average animation blend-
ing system similar to Ogre’s. Granny permits any number of animations to be
played on a single character simultaneously. The state of each active animation
is maintained in a data structure known as a granny_control. Granny cal-
culates a weighted average to determine the fi nal pose, automatically normal-
izing the weights of all active clips. In this sense, its architecture is virtually
identical to that of Ogre’s animation system. But where Granny really shines
is in its handling of time. Granny uses the global clock approach discussed in
Section 11.4.3. It allows each clip to be looped an arbitrary number of times or
infi nitely. Clips can also be time-scaled; a negative time scale allows an anima-
tion to be played in reverse.

11.10.3. Blend Trees
For reasons we’ll explore below, some animation engines represent their blend
specifi cations not as a fl at weighted average but as a tree of blend operations.
An animation blend tree is an example of what is known in compiler theory
as an expression tree or a syntax tree. The interior nodes of such a tree are opera-
tors, and the leaf nodes serve as the inputs to those operators. (More correctly,
the interior nodes represent the non-terminals of the grammar , while the leaf
nodes represent the terminals.) In the following sections, we’ll briefl y revisit
the various kinds of animation blends we learned about in Sections 11.6.3 and
11.6.5 and see how each can be represented by an expression tree.
Free download pdf