Game Development Reference
In-Depth Information
The premise behind H-Anim and any other skeletal representation is the
connection of straight segments and rotatable joints. The way in which
these structures move is analyzed by the applied mechanics discipline
of kinematics.
Kinematics describes the motion of objects without consideration of the
causes leading to the motion. It examines linear and rotational movement
with respect to distance, direction, and velocity. These are the very same
concepts developed in the previous chapter through the examination of
vector mathematics. Kinematics can be examined from two points
of view: forward and inverse.
Forward kinematics calculates the final position of the end of an articulated
object given the angle and rotation of the joints and the length of the
segments. To exemplify, forward kinematics can calculate the position of a
character's hand given the rotation and angles of joints and the length of
the bone segments. The hand in this case is what is known in kinematics
as the end effector. To solve such a problem, simple vector mathematics is
employed. Each bone has a length and direction that are specified as a vector.
Adding all the vectors together will give the final destination. As illustrated in
Figure 3.12 , if the shoulder is positioned at (10,10) with the humerus (upper
arm bone) making a vector of (3, - 3), the radius and ulna (lower arm bones)
making a vector of (2,2), and the hand with a vector of (1,0), the final position
of the finger tips will be at (16,9).
Inverse kinematics is used in games to ensure that characters connect
with the environment. For example, in The Sims , when a character
interacts with an object, the game must ensure that the character is
standing in the correct position to pick the object up. Although the
bending over and picking up an object is a premade animation, the
character still needs to be positioned in the correct location to perform
FIG 3.12 A forward kinematic
example with an arm in 2D.
(10,10)
(6,-1)
(16,9)
(3,-3)
(1,0)
(2,2)