Next on the agenda is, therefore, the transformations
to make the 3D objects move. The first of these
is very simple: if you walk towards an objects,
or back away, what happens? Well, the objects becomes
larger or smaller, but the perspective deals with
that; all we're worried about is the polygons' z-values.
If z increases into the monitor, then if you walk
towards some polygons, their z values must be decreased
as you walk towards them; and increased if you back
away from them. We assume that polygons with negative
z values are behind you, and so not visible. That's
the easy part; if you want to turn yourself, the
whole 3D world must be rotated about the place where
you are standing. This is a tricky business to work
out, but the secret is using matrix transformation
(this used to be in the GCSE maths course - seriously).
If your're unfamiliar with these it works like this.
A polygon is stored as a matrix of 3 rows (x,y and
z) and 4 columbs, one for each vertex. If this matrix
is multiplied by the correct transformation matrix,
then the polygon is effectively rotated about the
origin. Matrix multiplication is not as easy as
it sounds: effectively, each product is the sum
of the products of a columb times a row.
The matrix on the left represents one polygon; the
columbs contain the x, y and z coords of each vertex
respectivly. The matrix on the right is the transformation
matrix: more on that later. To generate the first
columb of the first row, the first row must be multiplied
by the first columb (always along the row first):
that is, each element (a,b,c) is multiplied by the
corresponding element (1,2,3) in the transformation
matrix, and the results summed, to give give the
result, A. This result is the x coordinate of the
first point of the transformed polygon. All 12 entries
are calculated in this way: and the result is a
polygon rotated about the origin. Critical to this
process, of course, is the transformation matrix.
Back to previous page | Next
page |