Graphics Reference
In-Depth Information
class UWBD3D _ MeshResource : public UWBD3D _ Resource {
public :
A:
void DrawMesh( ... );
// Render the mesh with D3D
.
const UWB _ BoundingBox * GetBoundingBox();
B:
// Bounds of the mesh object
.
protected :
C:
bool LoadResourceFromFile(fullPathName);
// Loading the .x mesh file
.
LPD3DXMESH m _ Mesh; // D3D-specific mesh storage
UWB _ Array<D3DMATERIAL9> m _ MeshMaterials; // Materials defined in the .x file
UWB _ Array<LPDIRECT3DTEXTURE9> m _ MeshTextures;
D:
// Textures defined in the .x file
.
UWB _ BoundingBox
m _ bounds;
// Bounds of the mesh object
bool UWBD3D _ MeshResource::LoadResourceFromFile( const wchar _ t * fullPathName) {
// Loads .x file (fullPathName) into m _ Mesh
D3DXLoadMeshFromX(fullPathName, ... m _ Mesh)
E:
Source file.
uwbgl _ D3DMeshResource1.h
file in the D3D Files/
D3D_Resources
. // if defined, loads file textures into m _ MeshTextures
// Computes m _ bound of the mesh object
subfolder
UWBGL _ D3D _ Lib15
of
the
project.
D3DXComputeBoundingBox(... m _ Mesh->GetNumVertices() )
.
F:
Listing 16.2. Support for mesh file resource.
will work with D3D to render the geometry defined in a .x mesh file. At label B,
proper bound information is maintained for the mesh geometry to support col-
lision computations (to be discussed in Section 16.6). The LoadResoruceFrom
File() function at label C will load the mesh file specified by fullPathName into
D3D. At label D, LPD3DXMESH is the D3D-specific representation for storing mesh
geometries, and the D3DMATERIAL9 and DIRECT3DTEXTURE9 arrays are defined to
store the material properties and (potential) file textures defined for the mesh ob-
ject. Label E shows the implementation of the LoadResourceFromFile() func-
tion where the mesh file is loaded into the LPD3DXMESH internal structure by the
D3DXLoadMeshFromX() function. Label F shows that we, as programmers, are
responsible for computing the bounds of a mesh object.
Search WWH ::




Custom Search