Mesh¶
-
struct
glen::Mesh¶ Raw mesh type.
Vertices define the points that make up the mesh. Indices should be provided in sets of three and define to connect the points with triangular faces.
Public Types
-
typedef GLushort
index_type¶
-
typedef std::vector<index_type>
indices_type¶
-
typedef std::vector<GLushort>::const_iterator
ind_iterator¶
Public Functions
-
Mesh()¶ Constructor.
Constructor.
- Parameters
vertices: The vertices that will make up the meshindices: The indices that will be used to specify the triangles of the mesh
-
~Mesh()¶ destructor
-
Mesh &
operator+=(Mesh &other)¶ Combine this mesh with another mesh.
- Return
The combined mesh
- Parameters
other: The other mesh
-
void
append_triangle(const Vertex vertex_1, const Vertex vertex_2, const Vertex vertex_3)¶ Add three vertices. Indices will need to be set up seperately.
-
void
append_index(const GLushort index)¶ Add a single index to a specify an existing vertex as part of a triangle.
This should be called in groups of three in order to add whole triangles.
- Parameters
index: Vertex index to add
-
void
transform(glm::mat4 transformMatrix)¶ Move all vertices in mesh according to
transformMatrix.
-
void
scale_uvs(const GLfloat amount)¶ Scale all UVs evenly. Useful for making use of tiled textures.
-
void
reverse_triangles()¶ Reverse the facing direction of all triangles in the mesh by reversing the winding direction.
-
void
make_indices_smooth()¶ Interpolate normals so faces appear smooth.
-
void
make_indices_faceted()¶ Don’t interpolate normals. All faces will appear flat.
-
void
make_tangents()¶ Automatically make all tangents and bitangents for mesh.
Properly set up tangents are required proper display.
-
index_type
get_index(std::size_t loc)¶ - Return
Vertex index located at
locin index array.
-
std::size_t
num_indices()¶ - Return
The number of indices.
-
std::size_t
num_vertices()¶ - Return
The number of vertices.
-
std::shared_ptr<vertices_type>
vertices()¶ - Return
Pointer to all vertices in the mesh.
-
const std::shared_ptr<indices_type> &
indices() const¶ - Return
Pointer to all indices in the mesh.
-
const GLuint
id() const¶ - Return
Unique ID for this mesh.
-
GLsizeiptr
size_vertices()¶ - Return
The size in bytes of all vertices in the mesh.
-
GLsizeiptr
size_indices()¶ - Return
The size in bytes of all indices in the mesh.
-
GLsizeiptr
size_shape()¶ - Return
The size in bytes of all indices and vertices in the mesh.
-
void
set_vertex_position(GLuint loc, glm::vec3 position)¶ Set vertex’s coordinates at index
loctoposition.
-
void
set_index(std::size_t loc, const index_type &data)¶ Set index at index array position
locto bedata.
-
void
set_id(GLuint s_id)¶
-
vrt_iterator
vert_begin()¶ - Return
Iterator to start of vertices.
-
vrt_iterator
vert_end()¶ - Return
Iterater to end of veritces.
-
ind_iterator
indx_begin()¶ - Return
Iterator to start of indices.
-
ind_iterator
indx_end()¶ - Return
Iterator to end of indies.
-
typedef GLushort
OBJ Loader¶
-
struct
glen::OBJ_Loader¶ OBJ Loader. At the moment, the obj files have to be in triangulated form.
Cylinder¶
-
struct
glen::Cylinder¶ Basic cylinder with cap.
Public Static Functions
-
Mesh
create_cylinder()¶ - Return
Default cylinder mesh with radius: 0.5, height: 2 and 24 faces around the side.
-
Mesh
create_cylinder(const float radius, const float height)¶ - Return
A cylinder mesh with given radius and height and 24 faces around the side.
- Parameters
radius: The radius of the cylinder.height: The height of the cylinder.
-
Mesh
create_cylinder(const float radius, const float height, const uint16_t width_segments, const uint16_t height_segments)¶ - Return
- Parameters
radius: The radius of the cylinder.height: The height of the cylinder.width_segments: The number of edges around the side. A higher number will result in a smoother cylinder.height_segments: The number of subdivisions going up the height of the cylinder. This will not affect the smoothness of the cylinder.
-
Mesh