#include <Mesh.h>
Public Types | |
enum | IndexFormat { INDEX8 = GL_UNSIGNED_BYTE, INDEX16 = GL_UNSIGNED_SHORT, INDEX32 = GL_UNSIGNED_INT } |
enum | PrimitiveType { TRIANGLES = GL_TRIANGLES, TRIANGLE_STRIP = GL_TRIANGLE_STRIP, LINES = GL_LINES, LINE_STRIP = GL_LINE_STRIP, POINTS = GL_POINTS } |
Public Member Functions | |
const char * | getUrl () const |
const VertexFormat & | getVertexFormat () const |
unsigned int | getVertexCount () const |
unsigned int | getVertexSize () const |
VertexBufferHandle | getVertexBuffer () const |
bool | isDynamic () const |
PrimitiveType | getPrimitiveType () const |
void | setPrimitiveType (Mesh::PrimitiveType type) |
void | setVertexData (const float *vertexData, unsigned int vertexStart=0, unsigned int vertexCount=0) |
MeshPart * | addPart (PrimitiveType primitiveType, Mesh::IndexFormat indexFormat, unsigned int indexCount, bool dynamic=false) |
unsigned int | getPartCount () const |
MeshPart * | getPart (unsigned int index) |
const BoundingBox & | getBoundingBox () const |
void | setBoundingBox (const BoundingBox &box) |
const BoundingSphere & | getBoundingSphere () const |
void | setBoundingSphere (const BoundingSphere &sphere) |
virtual | ~Mesh () |
Static Public Member Functions | |
static Mesh * | createMesh (const VertexFormat &vertexFormat, unsigned int vertexCount, bool dynamic=false) |
static Mesh * | createQuad (const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &p4) |
static Mesh * | createQuad (float x, float y, float width, float height, float s1=0.0f, float t1=0.0f, float s2=1.0f, float t2=1.0f) |
static Mesh * | createQuadFullscreen () |
static Mesh * | createLines (Vector3 *points, unsigned int pointCount) |
static Mesh * | createBoundingBox (const BoundingBox &box) |
Defines a mesh supporting various vertex formats and 1 or more MeshPart(s) to define how the vertices are connected.
Defines supported index formats.
Defines supported primitive types.
virtual gameplay::Mesh::~Mesh | ( | ) | [virtual] |
Destructor.
MeshPart* gameplay::Mesh::addPart | ( | PrimitiveType | primitiveType, |
Mesh::IndexFormat | indexFormat, | ||
unsigned int | indexCount, | ||
bool | dynamic = false |
||
) |
Creates and adds a new part of primitive data defining how the vertices are connected.
primitiveType | The type of primitive data to connect the indices as. |
indexFormat | The format of the indices. SHORT or INT. |
indexCount | The number of indices to be contained in the part. |
dynamic | true if the index data is dynamic; false otherwise. |
static Mesh* gameplay::Mesh::createBoundingBox | ( | const BoundingBox & | box | ) | [static] |
Creates a bounding box mesh when passed a BoundingBox.
The mesh contains only position data using lines to connect the vertices.
box | The BoundingBox that will be used to create the mesh. |
static Mesh* gameplay::Mesh::createLines | ( | Vector3 * | points, |
unsigned int | pointCount | ||
) | [static] |
Creates lines between 2 or more points passed in as a Vector3 array.
The mesh contains only position data using lines to connect the vertices. This is useful for drawing basic color elements into a scene.
points | The array of points. |
pointCount | The number of points. |
static Mesh* gameplay::Mesh::createMesh | ( | const VertexFormat & | vertexFormat, |
unsigned int | vertexCount, | ||
bool | dynamic = false |
||
) | [static] |
Constructs a new mesh with the specified vertex format.
vertexFormat | The vertex format. |
vertexCount | The number of vertices. |
dynamic | true if the mesh is dynamic; false otherwise. |
static Mesh* gameplay::Mesh::createQuad | ( | const Vector3 & | p1, |
const Vector3 & | p2, | ||
const Vector3 & | p3, | ||
const Vector3 & | p4 | ||
) | [static] |
Creates a new textured 3D quad.
The specified points should describe a triangle strip with the first 3 points forming a triangle wound in counter-clockwise direction, with the second triangle formed from the last three points in clockwise direction.
p1 | The first point. |
p2 | The second point. |
p3 | The third point. |
p4 | The fourth point. |
static Mesh* gameplay::Mesh::createQuad | ( | float | x, |
float | y, | ||
float | width, | ||
float | height, | ||
float | s1 = 0.0f , |
||
float | t1 = 0.0f , |
||
float | s2 = 1.0f , |
||
float | t2 = 1.0f |
||
) | [static] |
Constructs a new textured 2D quad.
x | The x coordinate. |
y | The y coordinate. |
width | The width of the quad. |
height | The height of the quad. |
s1 | The S texture coordinate of the bottom left point. |
t1 | The T texture coordinate of the bottom left point. |
s2 | The S texture coordinate of the top right point. |
t2 | The T texture coordinate of the top right point. |
static Mesh* gameplay::Mesh::createQuadFullscreen | ( | ) | [static] |
Creates a new full-screen 2D quad.
The returned mesh's vertex format includes a 2-element (x,y) position and a 2-element texture coordinate.
This method returns a mesh describing a fullscreen quad using normalized device coordinates for vertex positions.
const BoundingBox& gameplay::Mesh::getBoundingBox | ( | ) | const |
Returns the bounding box for the points in this mesh.
Only meshes loaded from bundle files are imported with valid bounding volumes. Programmatically created meshes will contain empty bounding volumes until the setBoundingBox and/or setBoundingSphere methods are called to specify the mesh's local bounds.
Meshes that are attached to a Model with a MeshSkin will have a bounding volume that is not necessarily tight fighting on the Mesh vertices. Instead, the bounding volume will be an approximation that contains all possible vertex positions in all possible poses after skinning is applied. This is necessary since skinning vertices result in vertex positions that lie outside the original mesh bounds and could otherwise result in a bounding volume that does not fully contain an animated/skinned mesh.
const BoundingSphere& gameplay::Mesh::getBoundingSphere | ( | ) | const |
Returns the bounding sphere for the points in the mesh.
Only meshes loaded from bundle files are imported with valid bounding volumes. Programmatically created meshes will contain empty bounding volumes until the setBoundingBox and/or setBoundingSphere methods are called to specify the mesh's local bounds.
Meshes that are attached to a Model with a MeshSkin will have a bounding volume that is not necessarily tight fighting on the Mesh vertices. Instead, the bounding volume will be an approximation that contains all possible vertex positions in all possible poses after skinning is applied. This is necessary since skinning vertices result in vertex positions that lie outside the original mesh bounds and could otherwise result in a bounding volume that does not fully contain an animated/skinned mesh.
MeshPart* gameplay::Mesh::getPart | ( | unsigned int | index | ) |
unsigned int gameplay::Mesh::getPartCount | ( | ) | const |
Gets the number of mesh parts contained within the mesh.
Returns the primitive type of the vertices in the mesh.
The default primitive type for a Mesh is TRIANGLES.
const char* gameplay::Mesh::getUrl | ( | ) | const |
Returns a URL from which the mesh was loaded from.
For meshes loaded from a Bundle, this URL will point to the file and ID of the mesh within the bundle. For all other meshes, an empty string will be returned.
VertexBufferHandle gameplay::Mesh::getVertexBuffer | ( | ) | const |
Returns a handle to the vertex buffer for the mesh.
unsigned int gameplay::Mesh::getVertexCount | ( | ) | const |
Gets the number of vertices in the mesh.
const VertexFormat& gameplay::Mesh::getVertexFormat | ( | ) | const |
Gets the vertex format for the mesh.
unsigned int gameplay::Mesh::getVertexSize | ( | ) | const |
Gets the size of a single vertex in the mesh.
bool gameplay::Mesh::isDynamic | ( | ) | const |
Determines if the mesh is dynamic.
void gameplay::Mesh::setBoundingBox | ( | const BoundingBox & | box | ) |
Sets the bounding box for this mesh.
box | The new bounding box for the mesh. |
void gameplay::Mesh::setBoundingSphere | ( | const BoundingSphere & | sphere | ) |
Sets the bounding sphere for this mesh.
sphere | The new bounding sphere for the mesh. |
void gameplay::Mesh::setPrimitiveType | ( | Mesh::PrimitiveType | type | ) |
Sets the primitive type for the vertices in the mesh.
The primitive type for a Mesh is only meaningful for meshes that do not have any MeshParts. When there are no MeshParts associated with a mesh, the Mesh is drawn as non-indexed geometry and the PrimitiveType of the Mesh determines how the vertices are interpreted when drawn.
type | The new primitive type. |
void gameplay::Mesh::setVertexData | ( | const float * | vertexData, |
unsigned int | vertexStart = 0 , |
||
unsigned int | vertexCount = 0 |
||
) |
Sets the specified vertex data into the mapped vertex buffer.
vertexData | The vertex data to be set. |
vertexStart | The index of the starting vertex (0 by default). |
vertexCount | The number of vertices to be set (default is 0, for all vertices). |