Game Engine Architecture

(Ben Green) #1

4.3. Matrices 163


increasing in the direction the camera is facing (left -handed) is typical because
it allows z coordinates to represent depths into the screen. Other engines and
APIs, such as OpenGL , defi ne view space to be right-handed, in which case the
camera faces towards negative z, and z coordinates represent negative depths.


4.3.10. Change of Basis


In games and computer graphics, it is oft en quite useful to convert an object’s
position, orientation, and scale from one coordinate system into another. We
call this operation a change of basis.


4.3.10.1. Coordinate Space Hierarchies


Coordinate frames are relative. That is, if you want to quantify the position,
orientation, and scale of a set of axes in three-dimensional space, you must
specify these quantities relative to some other set of axes (otherwise the num-
bers would have no meaning). This implies that coordinate spaces form a hi-
erarchy—every coordinate space is a child of some other coordinate space, and
the other space acts as its parent. World space has no parent; it is at the root
of the coordinate-space tree, and all other coordinate systems are ultimately
specifi ed relative to it, either as direct children or more-distant relatives.


4.3.10.2. Building a Change of Basis Matrix


The matrix that transforms points and directions from any child coordinate
system C to its parent coordinate system P can be writt en MCP→ (pronounced
“C to P”). The subscript indicates that this matrix transforms points and direc-
tions from child space to parent space. Any child-space position vector PC can
be transformed into a parent-space position vector PP as follows:


Left-Handed

x

z

y

Right- Handed

z

x

y Virtual
Screen ScreenVirtual

Figure 4.19. Left- and right-handed examples of view space, also known as camera space.

Free download pdf