Osiris Framework  0.3
OMesh Class Reference

Base class that represents a group of vertices that together make a geometrical shape. More...

#include <OsirisSDK/OMesh.h>

Inheritance diagram for OMesh:
OVertexColorMesh

Public Types

enum  CullFace { CullFace_Undefined =-1, CullFace_Front =GL_FRONT, CullFace_Back =GL_BACK }
 Sets which face will be rendered when face culling is available. More...
 
enum  CullFront { CullFront_Undefined =-1, CullFront_CW =GL_CW, CullFront_CCW =GL_CCW }
 In order to be able to ascertain which face is the front when dealing with face culling, we use the order in which the vertices are laid on each triangle. More...
 

Public Member Functions

 OMesh (OShaderProgram *program=NULL)
 Class constructor. More...
 
virtual ~OMesh ()
 Class destructor.
 
void setProgram (OShaderProgram *program)
 Sets a new shader program to be used to render the object. More...
 
OShaderProgramgetProgram ()
 Returns the shader program used to render the object. More...
 
int vertexCount () const
 Returns the number of vertices.
 
int faceCount () const
 Returns the number of faces.
 
void addVertexData (float vx, float vy, float vz)
 Add a vertex. More...
 
void addIndexData (GLuint vi, GLuint vj, GLuint vk)
 Define a single triangle by the vertex indices. More...
 
OVector3 vertexData (int idx) const
 Access vertex data. More...
 
OVector3 indexData (int idx) const
 Access index information. More...
 
void init ()
 Initializes the mesh buffers and shader attributes. More...
 
void render (OMatrixStack *mtx)
 Starts the rendering process for the object. More...
 
void setFaceCulling (bool enabled, CullFace face=CullFace_Undefined, CullFront front=CullFront_Undefined)
 Enables or disables face culling. More...
 

Protected Member Functions

virtual void setupAdditionalVertexArrays ()
 Virtual method to be used by derived classes to set additional vertex data.
 
virtual void setupAdditionalShaderLocations ()
 Virtual method to be used by derived classes to set additional shader parameters.
 
OMeshBuffer< float > * vertexBuffer ()
 Returns the mesh vertex buffer. More...
 
OMeshBuffer< GLuint > * indexBuffer ()
 Returns the mesh index buffer. More...
 
const OMeshBuffer< float > * vertexBufferConst () const
 Read-only method to obtain the vertex buffer. More...
 
const OMeshBuffer< GLuint > * indexBufferConst () const
 Read-only method to obtain the index buffer. More...
 

Detailed Description

Base class that represents a group of vertices that together make a geometrical shape.

Meshes are first defined by entering vertex data and indices. The mesh object can then be initialized and then redered.

Member Enumeration Documentation

Sets which face will be rendered when face culling is available.

See also
setFaceCulling()
Enumerator
CullFace_Undefined 

Undefined face.

CullFace_Front 

Front face.

CullFace_Back 

Back face.

In order to be able to ascertain which face is the front when dealing with face culling, we use the order in which the vertices are laid on each triangle.

See also
setFaceCulling()
Enumerator
CullFront_Undefined 

Undefined front face.

CullFront_CW 

Front face is defined by clockwise vertex order.

CullFront_CCW 

Front face is defined by counter-clockwise vertex order.

Constructor & Destructor Documentation

OMesh::OMesh ( OShaderProgram program = NULL)

Class constructor.

Parameters
programPointer to the shader program that will be used to render the object.

Member Function Documentation

void OMesh::addIndexData ( GLuint  vi,
GLuint  vj,
GLuint  vk 
)

Define a single triangle by the vertex indices.

Parameters
viFirst triangle vertex index.
vjSecond triangle vertex index.
vkThird triangle vertex index.
void OMesh::addVertexData ( float  vx,
float  vy,
float  vz 
)

Add a vertex.

Parameters
vxVertex X axis component.
vyVertex Y axis component.
vzVertex Z axis component.
OShaderProgram * OMesh::getProgram ( )

Returns the shader program used to render the object.

Returns
Pointer to the shader program object.
OMeshBuffer< GLuint > * OMesh::indexBuffer ( )
protected

Returns the mesh index buffer.

Returns
Pointer to the mesh index buffer.
const OMeshBuffer< GLuint > * OMesh::indexBufferConst ( ) const
protected

Read-only method to obtain the index buffer.

Returns
Const pointer to the mesh index buffer.
OVector3 OMesh::indexData ( int  idx) const

Access index information.

Parameters
idxFace index number.
Returns
OVector3 class object containing face vertex index data.
void OMesh::init ( )

Initializes the mesh buffers and shader attributes.

Must be called after all the vertex data is entered and before rendering.

void OMesh::render ( OMatrixStack mtx)

Starts the rendering process for the object.

Parameters
mtxPointer to the matrix stack that contains all the transformations.
void OMesh::setFaceCulling ( bool  enabled,
CullFace  face = CullFace_Undefined,
CullFront  front = CullFront_Undefined 
)

Enables or disables face culling.

Face culling is a feature designed to save perfomance. For three-dimentional and closed meshes, there is no need to render both sides of the triangles. By enabling face culling, only one face the triangles that makes the shape will be rendered by the rasterizer.

Parameters
enabledEnable flag.
faceFace that will be rendered.
frontDefines which face is the front, by the order in which the vertices are set on the triangles.
void OMesh::setProgram ( OShaderProgram program)

Sets a new shader program to be used to render the object.

Parameters
programPointer to the new shader program.
OMeshBuffer< float > * OMesh::vertexBuffer ( )
protected

Returns the mesh vertex buffer.

Returns
Pointer to the mesh vertex buffer.
const OMeshBuffer< float > * OMesh::vertexBufferConst ( ) const
protected

Read-only method to obtain the vertex buffer.

Returns
Const pointer to the mesh vertex buffer.
OVector3 OMesh::vertexData ( int  idx) const

Access vertex data.

Parameters
idxVertex index numbrt.
Returns
OVector3 class object containing vector coordinates.

The documentation for this class was generated from the following files: