#include <MeshBatch.h>
Public Member Functions | |
~MeshBatch () | |
unsigned int | getCapacity () const |
void | setCapacity (unsigned int capacity) |
Material * | getMaterial () const |
template<class T > | |
void | add (const T *vertices, unsigned int vertexCount, const unsigned short *indices=NULL, unsigned int indexCount=0) |
void | add (const float *vertices, unsigned int vertexCount, const unsigned short *indices=NULL, unsigned int indexCount=0) |
void | start () |
bool | isStarted () const |
void | finish () |
void | draw () |
Static Public Member Functions | |
static MeshBatch * | create (const VertexFormat &vertexFormat, Mesh::PrimitiveType primitiveType, const char *materialPath, bool indexed, unsigned int initialCapacity=1024, unsigned int growSize=1024) |
static MeshBatch * | create (const VertexFormat &vertexFormat, Mesh::PrimitiveType primitiveType, Material *material, bool indexed, unsigned int initialCapacity=1024, unsigned int growSize=1024) |
Defines a class for rendering multiple mesh into a single draw call on the graphics device.
Destructor.
void gameplay::MeshBatch::add | ( | const T * | vertices, |
unsigned int | vertexCount, | ||
const unsigned short * | indices = NULL , |
||
unsigned int | indexCount = 0 |
||
) |
Adds a group of primitives to the batch.
The vertex list passed in should be a pointer of structs, where the struct T represents the format of a single vertex (e.g. {x,y,z,u,v}).
If the batch was created with 'indexed' set to true, then valid index data should be passed in this method. However, if 'indexed' was set to false, the indices and indexCount parameters can be omitted since only vertex data will be used.
If the batch created to draw triangle strips, this method assumes that separate calls to add specify separate triangle strips. In this case, this method will automatically stitch separate triangle strips together using degenerate (zero-area) triangles.
vertices | Array of vertices. |
vertexCount | Number of vertices. |
indices | Array of indices into the vertex array (should be NULL for non-indexed batches). |
indexCount | Number of indices (should be zero for non-indexed batches). |
void gameplay::MeshBatch::add | ( | const float * | vertices, |
unsigned int | vertexCount, | ||
const unsigned short * | indices = NULL , |
||
unsigned int | indexCount = 0 |
||
) |
Adds a group of primitives to the batch.
The vertex list passed in should be a pointer of floats where every X floats represent a single vertex (e.g. {x,y,z,u,v}).
If the batch was created with 'indexed' set to true, then valid index data should be passed in this method. However, if 'indexed' was set to false, the indices and indexCount parameters can be omitted since only vertex data will be used.
If the batch created to draw triangle strips, this method assumes that separate calls to add specify separate triangle strips. In this case, this method will automatically stitch separate triangle strips together using degenerate (zero-area) triangles.
vertices | Array of vertices. |
vertexCount | Number of vertices. |
indices | Array of indices into the vertex array (should be NULL for non-indexed batches). |
indexCount | Number of indices (should be zero for non-indexed batches). |
static MeshBatch* gameplay::MeshBatch::create | ( | const VertexFormat & | vertexFormat, |
Mesh::PrimitiveType | primitiveType, | ||
const char * | materialPath, | ||
bool | indexed, | ||
unsigned int | initialCapacity = 1024 , |
||
unsigned int | growSize = 1024 |
||
) | [static] |
Creates a new mesh batch.
vertexFormat | The format of vertices in the new batch. |
primitiveType | The type of primitives that will be added to the batch. |
materialPath | Path to a material file to be used for drawing the batch. |
indexed | True if the batched primitives will contain index data, false otherwise. |
initialCapacity | The initial capacity of the batch, in triangles. |
growSize | Amount to grow the batch by when it overflows (a value of zero prevents batch growing). |
static MeshBatch* gameplay::MeshBatch::create | ( | const VertexFormat & | vertexFormat, |
Mesh::PrimitiveType | primitiveType, | ||
Material * | material, | ||
bool | indexed, | ||
unsigned int | initialCapacity = 1024 , |
||
unsigned int | growSize = 1024 |
||
) | [static] |
Creates a new mesh batch.
vertexFormat | The format of vertices in the new batch. |
primitiveType | The type of primitives that will be added to the batch. |
material | Material to be used for drawing the batch. |
indexed | True if the batched primitives will contain index data, false otherwise. |
initialCapacity | The initial capacity of the batch, in triangles. |
growSize | Amount to grow the batch by when it overflows (a value of zero prevents batch growing). |
void gameplay::MeshBatch::draw | ( | ) |
Draws the primitives currently in batch.
void gameplay::MeshBatch::finish | ( | ) |
Indicates that batching is complete and prepares the batch for drawing.
unsigned int gameplay::MeshBatch::getCapacity | ( | ) | const |
Returns the current capacity of the batch.
Material* gameplay::MeshBatch::getMaterial | ( | ) | const [inline] |
Returns the material for this mesh batch.
bool gameplay::MeshBatch::isStarted | ( | ) | const |
Determines if the batch has been started and not yet finished.
void gameplay::MeshBatch::setCapacity | ( | unsigned int | capacity | ) |
Explicitly sets a new capacity for the batch.
capacity | The new batch capacity. |
void gameplay::MeshBatch::start | ( | ) |
Starts batching.
This method should be called before calling add() to add primitives to the batch. After all primitives have been added to the batch, call the finish() method to complete the batch.
Calling this method will clear any primitives currently in the batch and set the position of the batch back to the beginning.