Game Development Reference
In-Depth Information
We label each subset by specifying a unique positive integer value for
that subset. This value can be any number that can be stored in a
DWORD . For instance, in Figure 10.1 we labeled the subsets 0, 1, 2, and
3.
Each triangle in the mesh is given an attribute ID that specifies the
subset in which the triangle lives. For example, from Figure 10.1, the
triangles that make up the floor of the house would have an attribute ID
of 0 to indicate that they live in subset 0. Similarly, the triangles that
make up the walls of the house have an attribute ID equal to 1 to indi-
cate that they live in subset 1.
The attribute IDs for the triangles are stored in the mesh's attrib-
ute buffer , which is a DWORD array. Since each face has an entry in the
attribute buffer, the number of elements in the attribute buffer is equal
to the number of faces in the mesh. The entries in the attribute buffer
and the triangles defined in the index buffer have a one-to-one corre-
spondence; that is, entry i in the attribute buffer corresponds with
triangle i in the index buffer. Triangle i is defined by the following three
indices in the index buffer:
A = i 3
B = i 3+1
C = i 3+2
Figure 10.2 shows this correspondence:
Figure 10.2: The correspondence between the triangles defined
in the index buffer and the entries in the attribute buffer. We
see that triangle 0 exists in subset 0, triangle 1 exists in subset
4, and triangle n exists in subset 2.
Search WWH ::




Custom Search