Game Engine Architecture

(Ben Green) #1
405

mesh.) This mesh is automatically detessellated as the object gets farther away
by collapsing certain edges. In eff ect, this process automatically generates a
semi-continuous chain of LODs. See htt p://research.microsoft .com/en-us/um/
people/hoppe/pm.pdf for a detailed discussion of progressive mesh technol-
ogy.


10.1.1.3. Constructing a Triangle Mesh


Now that we understand what triangle meshes are and why they’re used, let’s
take a brief look at how they’re constructed.


Winding Order


A triangle is defi ned by the position vectors of its three vertices, which we can
denote p 1 , p 2 , and p 3. The edges of a triangle can be found by simply subtract-
ing the position vectors of adjacent vertices. For example,


e 12 = p 2 – p 1 ,
e 13 = p 3 – p 1 ,
e 23 = p 3 – p 2.


The normalized cross product of any two edges defi nes a unit face normal N:


12 13
12 13


.

×
=
×

ee
N
ee

These derivations are illustrated in Figure 10.5. To know the direction of the
face normal (i.e., the sense of the edge cross product), we need to defi ne which
side of the triangle should be considered the front (i.e., the outside surface of
an object) and which should be the back (i.e., its inside surface). This can be
defi ned easily by specifying a winding order —clockwise (CW) or counterclock-
wise (CCW).
Most low-level graphics APIs give us a way to cull back-facing triangles
based on winding order. For example, if we set the cull mode parameter in Di-


Figure 10.5. Deriving the edges and plane of a triangle from its vertices.


p 1
p 2

p 3

e 12

N

e 13 e 23

10.1. Foundations of Depth-Buffered Triangle Rasterization

Free download pdf