Graphics Reference
In-Depth Information
Mesh Resource Storage Management
Recall from Listing 12.14 that we defined an array of
TextureResource
in the
GraphicsSystem
class to support file texture mapping. Listing 16.3 shows that
in a similar fashion, an array of
MeshResource
and the associated mesh load-
ing function are defined (at label B) in the
GraphicsSystem
class. The rest of
UWBGL
will access the mesh resource via the
.x
mesh filename by calling the
GetMeshResource()
function defined at label A. If a specified mesh filename is
not found in the mesh array, loading of the file will occur automatically.
3D Mesh Primitive Objects
With the
MeshResource
class (Listing 16.2) and the associated storage/manage-
ment support defined in the
GraphicsSystem
class (Listing 16.3), we can per-
ceive a mesh file/object as
just another primitive
. For example, with the sup-
port of appropriately defined vertex positions, we have worked with circle as a
Primitive
. In this case, we define the
PrimitiveMesh
class to abstract a mesh
file object as a simple mesh primitive. Listing 16.4 shows the definition of the
UWBD3D
_
PrimitiveMesh
class. We see a simple subclass from the
Primitive
class
UWBD3D
_
GraphicsSystem {
public
:
Source file.
uwbgl
_
D3DGraphicsSystem5.h
file in the
D3D Files/
D3D_GraphicsSystem
subfolder
// finds mesh MeshResource array
UWBD3D
_
MeshResource
*
GetMeshResource(meshname);
.
private
:
// MeshResources array
A:
of
the
UWBGL
_
D3D
_
Lib15
project.
UWB
_
PointerArray<UWBD3D
_
MeshResource
*
>m
_
mesh
_
resources;
// loads if not found in array
UWBD3D
_
MeshResource
*
FindMeshResource(mesh
_
name);
.
B:
.
from Listing
12.14
UWB
_
PointerArray<UWBD3D
_
TextureResource
*
>m
_
texture
_
resources;
// file texture support
UWBD3D
_
TextureResource
*
FindTextureResource(texture
_
name ...);
.
//
};
Listing 16.3.
Array of mesh resources in
UWBGL
.
Search WWH ::
Custom Search