Game Development Reference
In-Depth Information
Chapter 10
Meshes Part I
We have already worked with the
ID3DXMesh
interface using the
D3DXCreate*
routines; in this chapter we examine this interface in
more detail. This chapter is largely a survey of the data and methods
related to the
ID3DXMesh
interface.
Take note that the
ID3DXMesh
interface inherits the majority of its
functionality from its parent,
ID3DXBaseMesh
. This is important to
know because other mesh interfaces such as
ID3DXPMesh
(progres-
sive mesh) also inherit from
ID3DXBaseMesh
. Therefore the topics
covered in this chapter are also relevant when working with other
mesh types.
Objectives
To learn the internal data organization of an
ID3DXMesh
object
To learn how to create an
ID3DXMesh
To learn how to optimize an
ID3DXMesh
To learn how to render an
ID3DXMesh
10.1
Geometry Info
The
ID3DXBaseMesh
interface contains a vertex buffer that stores the
vertices of the mesh and an index buffer that defines how these verti-
ces are put together to form the triangles of the mesh. We can get a
pointer to these buffers using the following methods:
HRESULT ID3DXMesh::GetVertexBuffer(LPDIRECT3DVERTEXBUFFER9* ppVB);
HRESULT ID3DXMesh::GetIndexBuffer(LPDIRECT3DINDEXBUFFER9* ppIB);
Here is an example of how these methods are used:
IDirect3DVertexBuffer9* vb = 0;
Mesh->GetVertexBuffer( &vb );
IDirect3DIndexBuffer9* ib = 0;
Mesh->GetIndexBuffer( &ib );
160
Search WWH ::
Custom Search