Graphics Reference
In-Depth Information
class UWBD3D _ PrimitiveMesh :
public UWB _ Primitive {
Source file.
uwbgl _ D3DPrimitiveMesh1.h
file in the D3D Files/
D3D_Primitives
public :
subfolder
UWBD3D _ PrimitiveMesh( meshFileName ); // .x file name
.
protected :
A:
UWBGL _ D3D _ Lib15
of
the
project.
B:
void DrawPrimitive( ...);
// To draw the Mesh object
.
std::wstring m _ resource _ filename;
C:
// Internal representation of mesh object
.
void UWBD3D _ PrimitiveMesh::DrawPrimitive( ... ) {
.
// access mesh resource using the file name
UWBD3D _ MeshResource * pMesh=...GetMeshResource(m _ resource _ filename.c _ str());
// Calling D3D Mesh Rendering function
D:
E:
pMesh->DrawMesh( ... );
.
Listing 16.4. UWBGL primitive abstraction over mesh file object.
class. As expected, being a simple Primitive , we can work with the new Primi
tiveMesh just as we have worked with the PrimitivePoint or the Primitive
Circle classes! However, notice the D3D in the UWBD3D _ PrimitiveMesh class
name, and notice that we have placed the source file in the D3D Files subfolder.
This new primitive class defines a D3D-specific object. The most important
implication of this observation is that the drawing of the primitive will not be
handled by the DrawHelper class. Label B shows that we must override the
DrawPrimitive() class. The bottom half of Listing 16.4 shows the implemen-
tation of PrimitiveMesh . At label D, the GraphicsSystem class is invoked to
GetMeshResoruce() , and at label E we call the MeshResoruce::DrawMesh()
function directly to render the mesh object. There is no new mesh drawing sup-
port in the DrawHandler class. Listing 16.5 shows the MeshArrow class. Once
Source file.
uwbgl _ D3DPrimitiveArrow1.h
file in the D3D Files/
D3D_Primitives
again, this class defines a D3D-specific object. At label A, as in the case of
PrimitiveMesh , we see that we must override the DrawPrimitive() function.
In this case, we will approximate an arrow with appropriately scaled cone and
cylinder meshes. During DrawPrimitive() , at label B, references to the cone
and cylinder mesh resources are obtained via the GraphicsSystem::GetMeshRe
source() function. At labels C and D, the matrix stack is set up to scale and
subfolder
UWBGL _ D3D _ Lib15
of
the
project.
Search WWH ::




Custom Search