Game Development Reference
In-Depth Information
F IGURE 2.2
Left- and right-handed axes.
to the first two. If you label your fingers in order with the axes (thumb is X, fore-
finger Y, and middle finger Z), then you have a complete set of axes, either right- or
left-handed. Some people prefer to think of this in terms of the direction that a screw
is turned, but I find making axes with my hands much simpler.
Different game engines, rendering toolkits, and modeling software use either left-
or right-handed axes. There is no dependable standard. DirectX favors a left-handed
coordinate system, while OpenGL favors a right-handed one, as does the Render-
ware middleware system. XBox and XBox 360, being DirectX based, are left-handed;
GameCube, being rather OpenGL-like, is right-handed; and PlayStation's sample
code is right-handed, although most developers create their own rendering code. On
any platform you can actually use either with a bit more effort (this is how Ren-
derware uses a right-handed system even on the XBox, for example). For a detailed
explanation of different systems and converting between them see Eberly [2003].
There are relatively few places where it matters which system we use: it certainly
doesn't change the physics code in any way. I have (fairly arbitrarily) chosen right-
handed coordinates throughout this topic. Because the code on the CD is designed
to work with OpenGL, this makes the sample code slightly easier. In addition most
of the commercial engines I've worked with (both middleware and developers' own)
have been right-handed.
If you are working on a DirectX-only project and are keen to stay with a left-
handed system, then you'll need to make the occasional adjustment in the code. I'll
try to indicate places where this is the case.
2.1.2
V ECTORS AND D IRECTIONS
There is another interpretation of a vector. A vector can represent the change in po-
sition. Figure 2.3 shows an object that has moved in space from position a 0 to a 1 .
We can write down the change in position as a vector where each component of the