Game Development Reference
In-Depth Information
Figure 10.5: Screen shot of a
cube created and rendered
as an ID3DXMesh object
It demonstrates most of the functionality that we have discussed in this
chapter, including the following operations:
Creating an empty mesh
Filling the mesh with the geometry of a cube
Specifying the subset in which each face of the mesh exists
Generating the adjacency info of the mesh
Optimizing the mesh
Drawing the mesh
Note that we omit irrelevant code from the discussion of the sample.
You can find the complete source code in the companion files. This
sample is called D3DXCreateMeshFVF.
In addition, to facilitate debugging and investigating the compo-
nents of a mesh, we implement the following functions that dump its
internal contents to file:
void dumpVertices(std::ofstream& outFile, ID3DXMesh* mesh);
void dumpIndices(std::ofstream& outFile, ID3DXMesh* mesh);
void dumpAttributeBuffer(std::ofstream& outFile, ID3DXMesh* mesh);
void dumpAdjacencyBuffer(std::ofstream& outFile, ID3DXMesh* mesh);
void dumpAttributeTable(std::ofstream& outFile, ID3DXMesh* mesh);
The names of these functions describe their actions. Since the imple-
mentations of these functions are straightforward, we omit a discussion
of them here (see the source code in the companion files). However, we
do show an example of dumpAttributeTable later in this section.
To begin our review of the sample, we instantiate the following
global variables:
ID3DXMesh*
Mesh = 0;
const DWORD
NumSubsets = 3;
Search WWH ::




Custom Search