Game Development Reference

In-Depth Information

object can be stored in one of several ways including Euler angles,

angle axis or quaternions.

If the orientation is stored as Euler angles, then three scalar values are

used to hold the rotation of the object in the
x
-,
y
- and
z
-axes. We use

heading (
h
) to define the rotation in the
y
-axis, pitch (
p
) for the rotation

about the
x
-axis and bank (
b
) for the rotation about the
z
-axis. As we know

from Chapter 1, Euler angles describe a unique orientation only if we

know the order in which the rotations are applied. Euler angle rotation

suffers from the distinct disadvantage that gimbal lock occurs when a

rotation through 90° maps one axis onto another. If the order in which

rotations are applied is
HPB
, heading, pitch then bank problems can arise

with a rotation of 90° in the pitch. The effect of this rotation is to map the

z
-axis onto the
y
-axis; consequently, heading rotations about
y
seem to be

the same as bank rotations about
z
. This problem is very frustrating for

animators. For much of the last 5 years I have been running a company

where we use Lightwave for TV animation. Lightwave up to version 5.6

used Euler angles to store and interpolate the orientation. Sometimes

animators can get very annoyed with their monitors when it seems

impossible to bend a character into the orientation that they want. At this

point they become very aware of the problems of gimbal lock. Thankfully,

this annoying problem can be avoided with version 6+ of Newtek's

otherwise excellent software.

If the orientation is stored as angle axis, then four scalar values are

used. Three define a vector that describes the axis about which a rotation

takes place. The fourth value defines the angle of rotation about this axis.

This method has the advantage that it does not suffer from gimbal lock.

The final alternative is to use quarternions. This rather exotic mathemat-

ical device is the method of choice for interpolating orientation in many

computer games because it is computationally more efficient and gives

pleasing results.

As well as the ability to store the position, scale and orientation, we

need to store the time during the animation that we wish this to occur. We

could store the position, scale and orientation all together for a particular

time interval. But if we want total control over the way the character

animates, it is better that each channel of position, scale and orientation

is stored separately with its own time parameter. Using totally separate

channels ensures that interpolating a channel does not suffer from the

artefacts of another channel. Suppose that the
x
position moves smoothly

over the interval of 2 seconds. During this interval, the object rotates in a

complex fashion using keys at one third of a second intervals. If all

channels are stored for a key value, then the
x
position is stored at one

third of a second intervals. It will be more difficult to ensure a smooth

Search Nedrilad ::

Custom Search