template<typename T>
class cugl::Mesh< T >
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.
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.
- Parameters
-
other | The mesh to concatenate |
- Returns
- the concatenation of this mesh and other.
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.
- Parameters
-
poly | The polygon defining this mesh |
- Returns
- This polygon, returned for chaining
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.
- Parameters
-
poly | The polygon defining this mesh |
- Returns
- This polygon, returned for chaining
template<typename T>
Mesh& cugl::Mesh< T >::set |
( |
const std::vector< T > & |
verts, |
|
|
const std::vector< GLuint > & |
indx |
|
) |
| |
|
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.
- Parameters
-
verts | The vector of vertices (as floats) in this mesh |
indx | The vector of indices for the rendering |
- Returns
- This mesh for chaining
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.
- Parameters
-
start | The start index |
end | The end index |
- Returns
- the slice of this mesh between start and end.
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.
- Parameters
-
- Returns
- the slice of this mesh between start and end.
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.
- Parameters
-
- Returns
- the slice of this mesh between start and end.