CUGL 2.3
Cornell University Game Library
|
#include <CUMesh.h>
Public Member Functions | |
Mesh () | |
~Mesh () | |
Mesh (const Mesh &mesh) | |
Mesh (Mesh &&mesh) | |
Mesh (const Poly2 &poly) | |
Mesh & | operator= (const Mesh &other) |
Mesh & | operator= (Mesh &&other) |
Mesh & | operator= (const Poly2 &poly) |
Mesh & | set (const Mesh &other) |
Mesh & | set (const Poly2 &poly) |
Mesh & | set (const std::vector< T > &verts) |
Mesh & | set (const std::vector< T > &verts, const std::vector< GLuint > &indx) |
Mesh & | clear () |
Mesh & | operator*= (const Mat4 &transform) |
Mesh | operator* (const Mat4 &transform) const |
Mesh & | operator+= (const Mesh &other) |
Mesh | operator+ (const Mesh &other) const |
bool | isSliceable () const |
Mesh | slice (size_t start, size_t end) const |
Mesh | sliceFrom (size_t start) const |
Mesh | sliceTo (size_t end) const |
Public Attributes | |
std::vector< T > | vertices |
std::vector< GLuint > | indices |
GLenum | command |
This class represents an arbitrary drawing mesh.
A mesh is a collection of vertices, together with indices and a drawing command. The type of the indices and drawing command are fixed, but the vertex type is templated. This allows a mesh to be adapter to an arbitrary Shader
.
The only requirement of a mesh vertex is that it have at least one field called position, and this type be one of Vec2
, Vec3
or Vec4
.
|
inline |
Creates an empty mesh with no data.
Access the attributes to add data to the mesh.
|
inline |
Deletes the given mesh, freeing all resources.
|
inline |
Creates a copy of the given mesh.
Both the vertices and the indices are copied. No references to the original mesh are kept.
mesh | The mesh to copy |
|
inline |
Creates a copy with the resource of the given polygon.
It is unsafe to use the original mesh after this method is called.
mesh | The mesh to take from |
|
inline |
Creates a mesh from the given Poly2
object.
No vertex attribute other than position is set. Additional information (such as color or texture coordinate) must be added later. The command will be GL_TRIANGLES if the polygon is solid, GL_LINES if it is a path, and GL_UNDEFINED otherwise.
poly | The polygon defining this mesh |
|
inline |
Clears the contents of this mesh and sets the command to GL_LINES
|
inline |
Returns true is this mesh is sliceable.
The only sliceable mesh types are GL_LINES and GL_TRIANGLES. That is because the mesh is represented in regular, decomposable chunks. This method not only checks that the command is correct, but that the index size is correct as well.
|
inline |
Returns a new mesh by transforming the vertices of this one.
Because we allow meshes to be of arbitrary dimension, the only guaranteed safe transforms are Mat4
objects.
Note: This method does not modify the mesh.
transform | The transform matrix |
|
inline |
Transforms all of the vertices of this mesh.
Because we allow meshes to be of arbitrary dimension, the only guaranteed safe transforms are Mat4
objects.
transform | The transform matrix |
Return the concatenation of this mesh and other.
The vertices of other are appended to the end of this mesh. The indices are reindex to account for this shift.
This method will fail to append to the mesh if other does not share the same command as this mesh.
Note: This method does not modify the mesh.
other | The mesh to concatenate |
Appends the given mesh to this one.
The vertices of other are appended to the end of this mesh. The indices are reindex to account for this shift.
This method will fail to append to the mesh if other does not share the same command as this mesh.
other | The mesh to append |
Sets this mesh to be a copy of the given one.
All of the contents are copied, so that this mesh does not hold any references to elements of the other mesh. This method returns a reference to this mesh for chaining.
other | The mesh to copy |
|
inline |
Sets the mesh to match the Poly2
object.
No vertex attribute other than position is set. Additional information (such as color or texture coordinate) must be added later. The command will be GL_TRIANGLES if the polygon is solid, GL_LINES if it is a path, and GL_UNDEFINED otherwise.
This method returns a reference to this polygon for chaining.
poly | The polygon defining this mesh |
Sets this mesh to be have the resources of the given one.
It is unsafe to use the original mesh after this method is called.
This method returns a reference to this mesh for chaining.
other | The mesh to take from |
Sets this mesh to be a copy of the given one.
All of the contents are copied, so that this mesh does not hold any references to elements of the other mesh. This method returns a reference to this mesh for chaining.
other | The mesh to copy |
|
inline |
Sets the mesh to match the Poly2
object.
No vertex attribute other than position is set. Additional information (such as color or texture coordinate) must be added later. The command will be GL_TRIANGLES if the polygon is solid, GL_LINES if it is a path, and GL_UNDEFINED otherwise.
This method returns a reference to this polygon for chaining.
poly | The polygon defining this mesh |
|
inline |
Sets the mesh to have the given vertices
The resulting mesh has no indices. The command will be reset to GL_UNDEFINED.
This method returns a reference to this mesh for chaining.
verts | The vector of vertices (as Vec2) in this mesh |
|
inline |
Sets a mesh to have the given vertices and indices.
This method will assign a command according to the multiplicity of the indices. If the number of indices n is divisible by 3, it will be GL_TRIANGLES. Otherwise, if it is even, it will be GL_LINES. All other values will be undefined and the user must manually set the type.
This method returns a reference to this mesh for chaining.
verts | The vector of vertices (as floats) in this mesh |
indx | The vector of indices for the rendering |
|
inline |
Returns the slice of this mesh between start and end.
The sliced mesh will use the indices from start to end (not including end). It will include the vertices referenced by those indices, and only those vertices. The command will remain the same.
The only sliceable mesh types are GL_LINES and GL_TRIANGLES. That is because the mesh is represented in regular, decomposable chunks. Any attempt to slice another mesh type will fail.
start | The start index |
end | The end index |
|
inline |
Returns the slice of this mesh from the start index to the end.
The sliced mesh will use the indices from start to the end. It will include the vertices referenced by those indices, and only those vertices. The command will remain the same.
The only sliceable mesh types are GL_LINES and GL_TRIANGLES. That is because the mesh is represented in regular, decomposable chunks. Any attempt to slice another mesh type will fail.
start | The start index |
|
inline |
Returns the slice of this mesh from the begining to end.
The sliced mesh will use the indices up to (but not including) end. It will include the vertices referenced by those indices, and only those vertices. The command will remain the same.
The only sliceable mesh types are GL_LINES and GL_TRIANGLES. That is because the mesh is represented in regular, decomposable chunks. Any attempt to slice another mesh type will fail.
end | The end index |
GLenum cugl::Mesh< T >::command |
The OpenGL drawing command
std::vector<GLuint> cugl::Mesh< T >::indices |
The mesh indices, providing a shape to the vertices
std::vector<T> cugl::Mesh< T >::vertices |
The mesh vertices, to be passed to the shader