Game Development Reference
In-Depth Information
shadow must be a two-dimensional closed manifold. What this boils down to is
that every edge in a mesh must be shared by exactly two triangles, disallowing
any holes that would let us see the interior of the mesh.
Edge connectivity information must be precomputed so that we can deter-
mine a mesh's silhouette for shadow volume rendering. Suppose that we have an
indexed triangle mesh consisting of an array of N vertices
,
V and an
,
,
V
12
N
array of M triangles 1 ,,, M
T T . Each triangle simply indicates which three ver-
tices it uses by storing three integer indexes i , i , and i . We say that an index i
precedes an index i if the number p immediately precedes the number q in the
cyclic chain 1
. For instance, i precedes i and i precedes i , but i
→→→
231
does not precede i .
The indexes i , i , and i are ordered such that the positions of the vertices
V ,
V , and
V to which they refer are wound counterclockwise about the triangle's
normal vector. Suppose that two triangles share an edge whose endpoints are the
vertices V and V as shown in Figure 10.10. The consistent winding rule enforc-
es the property that for one of the triangles, the index referring to V precedes the
index referring to V , and that for the other triangle, the index referring to V pre-
cedes the index referring to V .
As demonstrated in Listing 10.1, the edges of a triangle mesh can be identi-
fied by making a single pass through the triangle list. For any triangle having ver-
tex indexes i , i , and i , we create an edge record for every instance in which
1
2
3
i
and store the index of the current triangle in the edge rec-
ord. This procedure creates exactly one edge for every pair of triangles that share
<
i
, 2
i
<
i
, or 3
i
<
i
2
3
1
V
a
i
i
3
3
i
2
i
1
i
i
1
2
V
Figure 10.10. When consistent winding is enforced, it is always the case that the indexes
referring to the vertices V and V of exactly one of the two triangles sharing an edge sat-
isfies the property that the index referring to
V precedes the index referring to V .