Game Development Reference
In-Depth Information
be consistent. Think about the triangle ABD as the tetrahedron rotates
about the y -axis. If this rotation is clockwise when viewed from above then
the vertex B moves right and the vertex D moves left. At a certain stage
the line BD is vertical. If the rotation continues then B is to the right of D.
At this stage in the rotation the face ABD is pointing away from the viewer.
Since we know that the order of the vertices read in a counter-clockwise
direction should be ABD, when the order changes to ADB, the triangle has
turned away from the viewer. This is very useful because in most
situations it is possible to effectively disregard this polygon. (If an object
is transparent then it will be necessary to continue to render back-facing
polygons.) We will look at other techniques to determine back-facing
polygons, but vertex order is always the most efficient to compute.
Polygon normals
A normal is simply a vector that points
directly out from a polygon. It is used in
computer graphics for determining lighting
levels, amongst other things. For the soft-
ware accompanying this topic we store the
normal for every polygon in a scene. We
have already seen how to deal with the sum
of two vectors. The method is easily exten-
ded to allow us to subtract two vectors:
Figure 1.4 A polygon normal.
[ x , y , z ]=[ x 1, y 1, z 1] - [ x 2, y 2, z 2]
=[ x 1- x 2, y 1- y 2, z 1- z 2]
For example,
[6, 0, 8] - [6, 3, 2] = [6 - 6, 0 - 3, 8 - 2]
= [0, -3, 6]
But what happens when we choose to multiply two vectors. In fact, there
are two methods of 'multiplying' vectors. One is referred to as the dot
product . This is defined as
a b =
a b cos(
) where 0
The symbol | a | refers to the magnitude of the vector a , which is defined
( x * x + y * y + z * z )
Search Nedrilad ::

Custom Search