Game Engine Architecture

(Ben Green) #1

162 4. 3D Math for Games


of the engines I’ve encountered use either a y-up or a z-up convention. The
y-up convention was probably an extension of the two-dimensional conven-
tion found in most mathematics textbooks, where the y-axis is shown going
up and the x-axis going to the right. The z-up convention is also common, be-
cause it allows a top-down orthographic view of the game world to look like
a traditional two-dimensional xy-plot.
As an example, let’s say that our aircraft ’s left wingtip is at (5, 0, 0) in mod-
el space. (In our game, front vectors correspond to the positive z-axis in model
space with y up, as shown in Figure 4.17.) Now imagine that the jet is facing
down the positive x-axis in world space, with its model-space origin at some
arbitrary location, such as (–25, 50, 8). Because the F vector of the airplane,
which corresponds to +z in model space, is facing down the +x-axis in world
space, we know that the jet has been rotated by 90 degrees about the world
y-axis. So if the aircraft were sitt ing at the world space origin, its left wingtip
would be at (0, 0, –5) in world space. But because the aircraft ’s origin has been
translated to (–25, 50, 8), the fi nal position of the jet’s left wingtip in model
space is (–25, 50, [8 – 5]) = (–25, 50, 3). This is illustrated in Figure 4.18.
We could of course populate our friendly skies with more than one Lear
jet. In that case, all of their left wingtips would have coordinates of (5, 0, 0)
in model space. But in world space, the left wingtips would have all sorts of
interesting coordinates, depending on the orientation and translation of each
aircraft.

4.3.9.3. View Space
View space (also known as camera space) is a coordinate frame fi xed to the cam-
era. The view space origin is placed at the focal point of the camera. Again,
any axis orientation scheme is possible. However, a y-up convention with z

Airport

zW

xW

xM

zM

(5,0,0)M


(–25,50,3)W


(–25,50,8)W


Aircraft:

Left
Wingtip:

Figure 4.18. A lear jet whose left wingtip is at (5, 0, 0) in model space. If the jet is rotated by 90
degrees about the world-space y-axis, and its model-space origin translated to (–25, 50, 8) in
world space, then its left wingtip would end up at (–25, 50, 3) when expressed in world space
coordinates.
Free download pdf