Osiris Framework
0.3
|
Base class that represents a group of vertices that together make a geometrical shape. More...
#include <OsirisSDK/OMesh.h>
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... | |
OShaderProgram * | getProgram () |
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... | |
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.
enum OMesh::CullFace |
Sets which face will be rendered when face culling is available.
Enumerator | |
---|---|
CullFace_Undefined |
Undefined face. |
CullFace_Front |
Front face. |
CullFace_Back |
Back face. |
enum OMesh::CullFront |
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.
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. |
OMesh::OMesh | ( | OShaderProgram * | program = NULL | ) |
Class constructor.
program | Pointer to the shader program that will be used to render the object. |
void OMesh::addIndexData | ( | GLuint | vi, |
GLuint | vj, | ||
GLuint | vk | ||
) |
Define a single triangle by the vertex indices.
vi | First triangle vertex index. |
vj | Second triangle vertex index. |
vk | Third triangle vertex index. |
void OMesh::addVertexData | ( | float | vx, |
float | vy, | ||
float | vz | ||
) |
Add a vertex.
vx | Vertex X axis component. |
vy | Vertex Y axis component. |
vz | Vertex Z axis component. |
OShaderProgram * OMesh::getProgram | ( | ) |
Returns the shader program used to render the object.
|
protected |
Returns the mesh index buffer.
|
protected |
Read-only method to obtain the index buffer.
OVector3 OMesh::indexData | ( | int | idx | ) | const |
Access index information.
idx | Face index number. |
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.
mtx | Pointer 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.
enabled | Enable flag. |
face | Face that will be rendered. |
front | Defines 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.
program | Pointer to the new shader program. |
|
protected |
Returns the mesh vertex buffer.
|
protected |
Read-only method to obtain the vertex buffer.
OVector3 OMesh::vertexData | ( | int | idx | ) | const |
Access vertex data.
idx | Vertex index numbrt. |