Track::DrawableMesh Class Reference

A mesh that can be drawn using OpenGL commands. More...

#include <DrawableMesh.h>

Inheritance diagram for Track::DrawableMesh:

Track::AABBDrawable Track::MeshFaces Track::Drawable Track::AABBBounded Track::AABBBounded Track::BulletMesh List of all members.

Public Types

 RM_WIREFRAME
 each face is drawn as a loop of lines
 RM_SOLID
 Complete textured faces.
enum  RenderMode { RM_WIREFRAME, RM_SOLID }
 Method for rendering. More...

Public Member Functions

 DrawableMesh (std::istream &source, RenderMode render_mode=RM_SOLID)
 construct by sucking information from an input stream.
 DrawableMesh (std::string filename, RenderMode render_mode=RM_SOLID)
 Construct from the contents of a file.
 DrawableMesh (const MeshFaces &mesh, RenderMode render_mode=RM_SOLID)
 construct from a MeshFaces obect
 DrawableMesh (RenderMode render_mode=RM_SOLID)
 construct an empty mesh
virtual ~DrawableMesh ()
virtual void draw () const
 Render the mesh using OpenGL commands.
virtual void make_cache () const
 Load the mesh into OpenGL to speed up first draw.
void set_render_mode (RenderMode new_render_mode)
 Control how the mesh is displayed.

Protected Member Functions

unsigned int * make_list () const
 Aquire a new display list when created without copying.

Static Protected Member Functions

static void delete_list (unsigned int *display_list)
 Delete the display list when all copies deleted.

Protected Attributes

unsigned int display_list
 OpenGL display list name where drawing instructions are stored.
boost::shared_ptr< unsigned
int > 
list_handle
 we use a shared_ptr so we can delete the display list when the last copy of the object is deleted.
RenderMode render_mode
 Method for drawing the mesh.

Detailed Description

A mesh that can be drawn using OpenGL commands.

The mesh's faces are defined using the vertex position, normal, and texture coordinates. Shaders / texturing / materials etc is left to the user.

Definition at line 26 of file DrawableMesh.h.


Member Enumeration Documentation

enum Track::DrawableMesh::RenderMode

Method for rendering.

Enumerator:
RM_WIREFRAME  each face is drawn as a loop of lines
RM_SOLID  Complete textured faces.

Definition at line 30 of file DrawableMesh.h.


Constructor & Destructor Documentation

Track::DrawableMesh::DrawableMesh ( std::istream &  source,
RenderMode  render_mode = RM_SOLID 
)

construct by sucking information from an input stream.

Equivalent to Track::MeshFaces::MeshFaces(std::istream &). Reads data from the stream to initlalise the mesh, and leaves the stream read position at the end of the DrawableMesh.

Parameters:
source The stream to use to initalise the mesh.
render_mode The method of displaying the mesh. You can set this later with set_render_mode() instead.

Definition at line 26 of file DrawableMesh.cpp.

Track::DrawableMesh::DrawableMesh ( std::string  filename,
RenderMode  render_mode = RM_SOLID 
)

Construct from the contents of a file.

Reads data from the file specified to initlalise the mesh.

Parameters:
filename The filename of the file to use.
render_mode The method of displaying the mesh. You can set this later with set_render_mode() instead.

Definition at line 40 of file DrawableMesh.cpp.

Track::DrawableMesh::DrawableMesh ( const MeshFaces mesh,
RenderMode  render_mode = RM_SOLID 
)

construct from a MeshFaces obect

Parameters:
mesh MeshFaces to use.
render_mode The method of displaying the mesh. You can set this later with set_render_mode() instead.

Definition at line 33 of file DrawableMesh.cpp.

Track::DrawableMesh::DrawableMesh ( RenderMode  render_mode = RM_SOLID  ) 

construct an empty mesh

Parameters:
render_mode The method of displaying the mesh. You can set this later with set_render_mode() instead.

Definition at line 47 of file DrawableMesh.cpp.

Track::DrawableMesh::~DrawableMesh (  )  [virtual]

Definition at line 53 of file DrawableMesh.cpp.


Member Function Documentation

void Track::DrawableMesh::delete_list ( unsigned int *  display_list  )  [static, protected]

Delete the display list when all copies deleted.

It is static to meet requirements of boost::shared_ptr.

Parameters:
display_list the display list number to remove. Should be that of the object that is being deleted.

Definition at line 160 of file DrawableMesh.cpp.

void Track::DrawableMesh::draw (  )  const [virtual]

Render the mesh using OpenGL commands.

Expects the texture and matrices to be set up already. Must be called outside of a glBegin/glEnd pair. Finishes with no change to the matrices, outside of a glBegin/glEnd pair.

Implements Track::Drawable.

Definition at line 57 of file DrawableMesh.cpp.

void Track::DrawableMesh::make_cache (  )  const [virtual]

Load the mesh into OpenGL to speed up first draw.

Requires the OpenGL context that will be used to draw active. Only needs to be called once, before draw is called. Calling it after draw is called or multiple times has no additional effect.

Definition at line 67 of file DrawableMesh.cpp.

unsigned int * Track::DrawableMesh::make_list (  )  const [protected]

Aquire a new display list when created without copying.

It generates the display from the MeshFaces data.

Returns:
the display_list of the object.

Definition at line 75 of file DrawableMesh.cpp.

void Track::DrawableMesh::set_render_mode ( RenderMode  new_render_mode  ) 

Control how the mesh is displayed.

If the new RenderMode is the same as the previous, there is no effect. Otherwise this will unset the cache created by a previous call to draw() or make_cache(), if any. The deafult RenderMode is RM_SOLID.

Parameters:
new_render_mode The method used by draw() or make_cache().

Definition at line 165 of file DrawableMesh.cpp.


Member Data Documentation

unsigned int Track::DrawableMesh::display_list [mutable, protected]

OpenGL display list name where drawing instructions are stored.

Definition at line 90 of file DrawableMesh.h.

boost::shared_ptr<unsigned int> Track::DrawableMesh::list_handle [mutable, protected]

we use a shared_ptr so we can delete the display list when the last copy of the object is deleted.

Definition at line 95 of file DrawableMesh.h.

RenderMode Track::DrawableMesh::render_mode [protected]

Method for drawing the mesh.

Definition at line 111 of file DrawableMesh.h.


The documentation for this class was generated from the following files:
Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:18 2010 by Doxygen version 1.4.7 for Racer version svn335.