Game Development Reference
In-Depth Information
A = i 3
B = i 3+1
C = i 3+2
Note that an entry of ULONG_MAX = 4294967295 as its value indi-
cates that the particular edge does not have an adjacent triangle. We
can also use -1 to denote this because assigning -1 to a DWORD results
in ULONG_MAX . To see this, recall that a DWORD is an unsigned 32-bit
integer.
Since each triangle has three edges, it can have up to three adja-
cent triangles (see Figure 10.4).
Figure 10.4: We see that
each triangle has three
entries in the adjacency
array that identify the trian-
gles adjacent to it. For
instance, Tri: 1 has two
adjacent triangles ( Tri: 0
and Tri: 2 ). Thus for Tri:
1 there is a 0, 2, and -1 in
its corresponding adjacency
entries specifying that Tri:
0 and Tri: 2 are adjacent.
The -1 indicates that one
edge of Tri: 1 doesn't have
an adjacent triangle.
Therefore, the adjacency array must have (ID3DXBaseMesh::Get-
NumFaces() * 3) elements—three possible adjacent triangles for
every triangle in the mesh.
Many of the D3DX mesh creation functions can output the adja-
cency info, but the following method can also be used:
HRESULT ID3DXMesh::GenerateAdjacency(
FLOAT fEpsilon,
DWORD* pAdjacency
);
fEpsilon —An epsilon value specifying when two points are close
enough in distance that they should be treated as the same. For
instance, if the distance between two points is less than epsilon, we
treat them as the same.
pAdjacency —A pointer to an array of DWORDs that is to be filled
with the adjacency info
Search WWH ::




Custom Search