Game Development Reference
In-Depth Information
convert other popular mesh file formats to .X. Now, what makes XFiles
convenient is that they are a DirectX defined format, and therefore the
D3DX library readily supports XFiles. That is, the D3DX library pro-
vides functions for loading and saving XFiles. Thus, we avoid having to
write our own file loading/saving routines if we use this format.
Note: You can download the DirectX9 SDK Extra—Direct3D Tools
package from MSDN at http://www.msdn.microsoft.com/ to get some
already made .X exporters for popular 3D modelers like 3DS Max,
LightWave, and Maya.
11.2.1 Loading an XFile
We use the following function to load the mesh data stored in an XFile.
Note that this method creates an ID3DXMesh object and loads the geo-
metric data of the XFile into it.
HRESULT D3DXLoadMeshFromX(
LPCSTR pFilename,
DWORD Options,
LPDIRECT3DDEVICE9 pDevice,
LPD3DXBUFFER *ppAdjacency,
LPD3DXBUFFER *ppMaterials,
LPD3DXBUFFER* ppEffectInstances,
PDWORD pNumMaterials,
LPD3DXMESH *ppMesh
);
pFilename —The filename of the XFile to load
Options —One or more creation flags that are used to create the
mesh. See the D3DXMESH enumerated type in the SDK documenta-
tion for a complete list of option flags. Some common flags are:
D3DXMESH_32BIT —The mesh will use 32-bit indices.
D3DXMESH_MANAGED —The mesh will be placed in the man-
aged memory pool.
D3DXMESH_WRITEONLY —The mesh's data will only be writ-
ten to and not read from.
D3DXMESH_DYNAMIC —The mesh's buffers will be made
dynamic.
pDevice —The device to be associated with the mesh
ppAdjacency —Returns an ID3DXBuffer containing a DWORD
array that describes the adjacency info of the mesh
ppMaterials —Returns an ID3DXBuffer containing an array of
D3DXMATERIAL structures that contains the material data for this
mesh. We cover the mesh materials in the following section.
Search WWH ::




Custom Search