Game Development Reference
In-Depth Information
{
Device->SetTexture( 0, Textures[i] );
Mesh->DrawSubset( i );
}
Device->EndScene();
Device->Present(0, 0, 0, 0);
}
return true;
}
10.10 Summary
A mesh contains a vertex, index, and attribute buffer. The vertex
and index buffer hold the geometry of the mesh (vertices and trian-
gles). The attribute buffer contains a corresponding entry for each
triangle and specifies the subset to which a triangle belongs.
A mesh can be optimized with the OptimizeInplace or Opti-
mize method. Optimization reorganizes the geometry of the mesh
to make rendering more efficient. Optimizing a mesh with
D3DXMESHOPT_ATTRSORT generates an attribute table. An attrib-
ute table allows the mesh to render an entire subset using a simple
lookup into the attribute table.
The adjacency info of a mesh is a DWORD array that contains three
entries for every triangle in the mesh. The three entries corre-
sponding to a particular triangle specify the triangles that are adja-
cent to that triangle.
We can create an empty mesh using the D3DXCreateMeshFVF
function. We can then write valid data to the mesh using the appro-
priate locking methods ( LockVertexBuffer , LockIndexBuf-
fer , and LockAttributeBuffer ).
Search WWH ::




Custom Search