Game Development Reference
In-Depth Information
Note: For your information only, the ID3DXMesh interface supports
indexed triangle lists only as its primitive type.
Alternatively, if we just want to lock the buffers to read or write to
them, we can use this next pair of methods. Note that these methods
lock the entire vertex/index buffer.
HRESULT ID3DXMesh::LockVertexBuffer(DWORD Flags, BYTE** ppData);
HRESULT ID3DXMesh::LockIndexBuffer(DWORD Flags, BYTE** ppData);
The Flags parameter describes how the lock is done. Locking flags for
a vertex/index buffer is explained in Chapter 3 where we first intro-
duced buffers. The ppData argument is the address of a pointer that is
to point to the locked memory when the function returns.
Remember to call the appropriate unlock method when you are
done with the lock:
HRESULT ID3DXMesh::UnlockVertexBuffer();
HRESULT ID3DXMesh::UnlockIndexBuffer();
Below is a list of additional ID3DXMesh methods used to obtain geome-
try-related information:
DWORD GetFVF(); —Returns a DWORD describing the vertex for-
mat of the vertices
DWORD GetNumVertices(); —Returns the number of vertices
in the vertex buffer
DWORD GetNumBytesPerVertex(); —Returns the number of
bytes per vertex
DWORD GetNumFaces(); —Returns the number of faces (trian-
gles) in the mesh
10.2 Subsets and the Attribute Buffer
A mesh consists of one or more subsets. A subset is a group of triangles
in the mesh that can all be rendered using the same attribute. By attrib-
ute we mean material, texture, and render states. Figure 10.1 illustrates
how a mesh representing a house may be divided into several subsets.
Figure 10.1: A
house broken up
into subsets
Search WWH ::




Custom Search