Game Development Reference
In-Depth Information
The first step in this process is to use a model matrix to convert the vertices from
model space into world space . Each vertex in the model is multiplied by the model
matrix, which will first rotate and scale the vertices so that the model is orientated
correctly, then translate each point so that the model's pivot point is now at the
translation provided in the matrix.
Now that all our vertices are positioned correctly in our virtual world, the next step
is to convert them into view space , which is the coordinate system defined by the
position and orientation of our viewpoint, which for obvious reasons is normally
referred to as our camera. We do this by providing another matrix called the view
matrix (or camera matrix if you prefer), which will rotate, scale, and translate the
world space vertices so that they are now relative to our camera view.
With the vertices now in view space, the final operation is to convert the vertices into
2D screen coordinates. We have two ways of doing this, these being an orthographic
projection or a perspective projection .
An orthographic projection takes the view space coordinates and just scales and
translates the x and y components of each vertex to put them onto the screen. The z
component of the vertex plays no part in calculating the actual screen coordinates
but it is used for working out the drawing order of polygons since it is used as a
depth value.
However, in most cases we use a perspective projection. Again the x and y
components of each view space vertex are used to generate the x and y screen
coordinates, but this time they are divided by the z component of the vertex,
which has the effect of making objects that are further away appear smaller.
The components are also multiplied by a constant value called the perspective
multiplier . This value is actually the distance at which the view plane lies from
the camera. The view plane is the plane which contains the rectangular area of
the screen display.
Normally, when we think about a camera view it is more convenient to think
about the field of view , which is the horizontal angle of our viewing cone.
The following diagram shows how we can convert this angle into the correct
perspective multiplier value:
 
Search WWH ::




Custom Search