|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Static Public Member Functions
gameplay::MeshBatch Class Reference

`#include <MeshBatch.h>`

List of all members.

## 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)

## Detailed Description

Defines a class for rendering multiple mesh into a single draw call on the graphics device.

## Constructor & Destructor Documentation

gameplay::MeshBatch::~MeshBatch | ( |  | ) |

Destructor.

## Member Function Documentation

template<class T >

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.

Parameters:

  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.

Parameters:

  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.

Parameters:

  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).

Returns:
  A new mesh batch.

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.

Parameters:

  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).

Returns:
  A new mesh batch.

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.

Returns:
  The batch capacity.

Material* gameplay::MeshBatch::getMaterial | ( |  | ) | const`[inline]`

Returns the material for this mesh batch.

Returns:
  The material used to draw the 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.

Parameters:

  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.

All Classes Functions Variables Typedefs Enumerations Enumerator