sgltk 0.6
Simple OpenGL Tool Kit
Loading...
Searching...
No Matches
sgltk::Mesh Class Reference

Manages meshes. More...

#include <mesh.h>

Collaboration diagram for sgltk::Mesh:

Public Member Functions

void setup_shader (Shader *shader)
 Specifies the shader to use to render the mesh.
bool setup_camera (glm::mat4 *view_matrix, glm::mat4 *projection_matrix)
 Sets up the view and projection matrices that will be used by the mesh.
bool setup_camera (Camera *camera)
 Sets up the view and projection matrices that will be used by the mesh.
void set_model_matrix_name (const std::string &name)
 Sets the name of the model matrix in the shader.
void set_view_matrix_name (const std::string &name)
 Sets the name of the view matrix in the shader.
void set_projection_matrix_name (const std::string &name)
 Sets the name of the projection matrix in the shader.
void set_model_view_matrix_name (const std::string &name)
 Sets the name of the model-view matrix in the shader.
void set_view_proj_matrix_name (const std::string &name)
 Sets the name of the view-projection matrix in the shader.
void set_model_view_proj_name (const std::string &name)
 Sets the name of the model-view-projection matrix in the shader.
void set_normal_matrix_name (const std::string &name)
 Sets the name of the normal matrix in the shader.
void set_ambient_color_name (const std::string &name)
 Sets the name of the ambient color in the shader.
void set_diffuse_color_name (const std::string &name)
 Sets the name of the diffuse color in the shader.
void set_specular_color_name (const std::string &name)
 Sets the name of the specular color in the shader.
void set_shininess_name (const std::string &name)
 Sets the name of the shininess of the material in the shader.
void set_shininess_strength_name (const std::string &name)
 Sets the name of the shininess strength of the material in the shader.
void attach_texture (const std::string &name, const sgltk::Texture &texture, unsigned int index=0)
 Attaches a texture to the mesh.
void set_transform_feedback_mode (GLenum mode)
 Sets the output type for transform feedback operations.
void attach_buffer (const sgltk::Buffer *buffer, GLuint target, unsigned int index=0)
 Attaches a buffer that is automatically bound before each draw call.
template<typename T>
unsigned int attach_vertex_buffer (const T *vertexdata, unsigned int number_elements, GLenum usage=GL_STATIC_DRAW)
 Loads data into memory.
template<typename T>
unsigned int attach_vertex_buffer (const std::vector< T > &vertexdata, GLenum usage=GL_STATIC_DRAW)
 Loads data into memory.
template<typename T>
bool replace_buffer_data (unsigned int buffer_index, const T *data, unsigned int number_elements)
 Overwrites all data in a vertex buffer.
template<typename T>
bool replace_buffer_data (unsigned int buffer_index, const std::vector< T > &data)
 Overwrites all data in a vertex buffer.
template<typename T>
bool replace_partial_data (unsigned int buffer_index, unsigned int offset, const T *data, unsigned int number_elements)
 Modifies the data in a vertex buffer.
template<typename T>
bool replace_partial_data (unsigned int buffer_index, unsigned int offset, const std::vector< T > &data)
 Modifies the data in a vertex buffer.
template<typename T>
int add_vertex_attribute (std::string attrib_name, GLint number_elements, GLenum type, const T *data, GLenum usage=GL_STATIC_DRAW)
 This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute.
template<typename T>
int add_vertex_attribute (std::string attrib_name, GLint number_elements, GLenum type, const std::vector< T > &data, GLenum usage=GL_STATIC_DRAW)
 This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute.
template<typename T>
int add_vertex_attribute (int attrib_location, GLint number_elements, GLenum type, const T *data, GLenum usage=GL_STATIC_DRAW)
 This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute.
template<typename T>
int add_vertex_attribute (int attrib_location, GLint number_elements, GLenum type, const std::vector< T > &data, GLenum usage=GL_STATIC_DRAW)
 This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute.
int set_buffer_vertex_attribute (const std::string &attrib_name, sgltk::Buffer *buffer, GLint number_elements, GLenum type, GLsizei stride, const GLvoid *pointer, unsigned int divisor=0)
 Sets pointers to vertex attributes.
int set_buffer_vertex_attribute (int attrib_location, sgltk::Buffer *buffer, GLint number_elements, GLenum type, GLsizei stride, const GLvoid *pointer, unsigned int divisor=0)
 Sets pointers to vertex attributes.
int set_vertex_attribute (const std::string &attrib_name, unsigned int buffer_index, GLint number_elements, GLenum type, GLsizei stride, const GLvoid *pointer, unsigned int divisor=0)
 Sets pointers to vertex attributes.
int set_vertex_attribute (int attrib_location, unsigned int buffer_index, GLint number_elements, GLenum type, GLsizei stride, const GLvoid *pointer, unsigned int divisor=0)
 Sets pointers to vertex attributes.
template<typename T>
int attach_index_buffer (const std::vector< T > &indices)
 Attaches an index array to the mesh.
template<typename T>
void compute_bounding_box (const std::vector< T > &vertexdata, unsigned int pointer)
 Computes the bounding box of the mesh.
void draw (GLenum mode)
 Renders the mesh using the first index buffer.
void draw (GLenum mode, const glm::mat4 *model_matrix)
 Renders the mesh using the first index buffer.
void draw (GLenum mode, unsigned int index_buffer, const glm::mat4 *model_matrix)
 Renders the mesh.
void draw_instanced (GLenum mode, unsigned int num_instances)
 Renders the mesh multiple times.
void draw_instanced (GLenum mode, unsigned int index_buffer, unsigned int num_instances)
 Renders the mesh multiple times.
template<>
int attach_index_buffer (const std::vector< unsigned char > &indices)
template<>
int attach_index_buffer (const std::vector< unsigned short > &indices)
template<>
int attach_index_buffer (const std::vector< unsigned int > &indices)

Public Attributes

unsigned int num_uv
 Number of texture coordinates.
unsigned int num_col
 Number of vertex colors.
unsigned int num_vertices
 Number of vertices.
std::string ambient_color_name
 The name of the ambient materiel component.
std::string diffuse_color_name
 The name of the diffuse materiel component.
std::string specular_color_name
 The name of the specular materiel component.
std::string shininess_name
 The name of the specular factor.
std::string shininess_strength_name
 The name of the specular exponent.
std::string model_matrix_name
 The name of the model matrix in the shader.
std::string view_matrix_name
 The name of the view matrix in the shader.
std::string projection_matrix_name
 The name of the projection matrix in the shader.
std::string model_view_matrix_name
 The name of the model-view matrix in the shader.
std::string view_proj_matrix_name
 The name of the view-projection matrix in the shader.
std::string model_view_projection_matrix_name
 The name of the model-view-projection matrix in the shader.
std::string normal_matrix_name
 The name of the normal matrix in the shader.
Shadershader
 The shader being used to draw the mesh.
std::vector< glm::vec3 > bounding_box
 The bounding box.
glm::mat4 model_matrix
 The model matrix.
float shininess
 The shininess of the material.
float shininess_strength
 The strength of the shininess of the material.
glm::vec4 color_ambient
 The ambient color component of the material.
glm::vec4 color_diffuse
 The diffuse color component of the material.
glm::vec4 color_specular
 The specular color component of the material.
std::vector< std::tuple< std::string, const Texture &, unsigned int > > auto_textures
 Attached textures.
std::vector< std::tuple< std::string, const Texture &, unsigned int > > textures
 Attached user textures.
bool wireframe
 Indicates that the mesh should be drawn as a wireframe.
bool twosided
 Indicates that the mesh should not be drawn using back face culling.

Detailed Description

Manages meshes.

Definition at line 139 of file mesh.h.

Constructor & Destructor Documentation

◆ Mesh()

Mesh::Mesh ( )

Definition at line 5 of file mesh.cpp.

◆ ~Mesh()

Mesh::~Mesh ( )

Definition at line 41 of file mesh.cpp.

Member Function Documentation

◆ add_vertex_attribute() [1/4]

template<typename T>
int sgltk::Mesh::add_vertex_attribute ( int attrib_location,
GLint number_elements,
GLenum type,
const std::vector< T > & data,
GLenum usage = GL_STATIC_DRAW )

This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute.

Parameters
attrib_locationThe attribute location in the shader
number_elementsNumber of elements
typeElement type
dataThe vertices to be loaded into memory
usageA hint as to how the buffer will be accessed. Valid values are GL_{STREAM,STATIC,DYNAMIC}_{DRAW,READ,COPY}.
Returns
Returns 0 on success, -1 if no shader was specified for the mesh, -2 if the vertex attribute could not be found

Definition at line 754 of file mesh.h.

◆ add_vertex_attribute() [2/4]

template<typename T>
int sgltk::Mesh::add_vertex_attribute ( int attrib_location,
GLint number_elements,
GLenum type,
const T * data,
GLenum usage = GL_STATIC_DRAW )

This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute.

Parameters
attrib_locationThe attribute location in the shader
number_elementsNumber of elements
typeElement type
dataThe vertices to be loaded into memory
usageA hint as to how the buffer will be accessed. Valid values are GL_{STREAM,STATIC,DYNAMIC}_{DRAW,READ,COPY}.
Returns
Returns 0 on success, -1 if no shader was specified for the mesh, -2 if the vertex attribute could not be found

Definition at line 742 of file mesh.h.

◆ add_vertex_attribute() [3/4]

template<typename T>
int sgltk::Mesh::add_vertex_attribute ( std::string attrib_name,
GLint number_elements,
GLenum type,
const std::vector< T > & data,
GLenum usage = GL_STATIC_DRAW )

This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute.

Parameters
attrib_nameThe attribute name in the shader
number_elementsNumber of elements
typeElement type
dataThe vertices to be loaded into memory
usageA hint as to how the buffer will be accessed. Valid values are GL_{STREAM,STATIC,DYNAMIC}_{DRAW,READ,COPY}.
Returns
Returns 0 on success, -1 if no shader was specified for the mesh, -2 if the vertex attribute could not be found

Definition at line 731 of file mesh.h.

◆ add_vertex_attribute() [4/4]

template<typename T>
int sgltk::Mesh::add_vertex_attribute ( std::string attrib_name,
GLint number_elements,
GLenum type,
const T * data,
GLenum usage = GL_STATIC_DRAW )

This is a convenience function that combines attach_vertex_buffer and set_vertex_attribute.

Parameters
attrib_nameThe attribute name in the shader
number_elementsNumber of elements
typeElement type
dataThe vertices to be loaded into memory
usageA hint as to how the buffer will be accessed. Valid values are GL_{STREAM,STATIC,DYNAMIC}_{DRAW,READ,COPY}.
Returns
Returns 0 on success, -1 if no shader was specified for the mesh, -2 if the vertex attribute could not be found

Definition at line 719 of file mesh.h.

◆ attach_buffer()

void Mesh::attach_buffer ( const sgltk::Buffer * buffer,
GLuint target,
unsigned int index = 0 )

Attaches a buffer that is automatically bound before each draw call.

Parameters
bufferThe buffer to attach_buffer
targetThe target the buffer will be bound to
indexThe index of the binding point within the array specified by target.
Note
If the target of the buffer is not GL_ATOMIC_COUNTER_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER, GL_UNIFORM_BUFFER or GL_SHADER_STORAGE_BUFFER the index is ignored.

Definition at line 170 of file mesh.cpp.

◆ attach_index_buffer() [1/4]

template<typename T>
int sgltk::Mesh::attach_index_buffer ( const std::vector< T > & indices)

Attaches an index array to the mesh.

Parameters
indicesIndices describing the topology of the mesh
Returns
Returns the index of the index-buffer or -1 on failure. This function will fail if the index type does not match that of an already attached buffer
Note
You can attach multiple index arrays

◆ attach_index_buffer() [2/4]

template<>
int sgltk::Mesh::attach_index_buffer ( const std::vector< unsigned char > & indices)
inline

Definition at line 836 of file mesh.h.

◆ attach_index_buffer() [3/4]

template<>
int sgltk::Mesh::attach_index_buffer ( const std::vector< unsigned int > & indices)
inline

Definition at line 860 of file mesh.h.

◆ attach_index_buffer() [4/4]

template<>
int sgltk::Mesh::attach_index_buffer ( const std::vector< unsigned short > & indices)
inline

Definition at line 848 of file mesh.h.

◆ attach_texture()

void Mesh::attach_texture ( const std::string & name,
const sgltk::Texture & texture,
unsigned int index = 0 )

Attaches a texture to the mesh.

Parameters
nameThe name of the texture in the shader
textureThe texture to attach
indexThe index of the texture in the uniform array

Definition at line 159 of file mesh.cpp.

◆ attach_vertex_buffer() [1/2]

template<typename T>
unsigned int sgltk::Mesh::attach_vertex_buffer ( const std::vector< T > & vertexdata,
GLenum usage = GL_STATIC_DRAW )

Loads data into memory.

Parameters
vertexdataThe data to be loaded into memory
usageA hint as to how the buffer will be accessed. Valid values are GL_{STREAM,STATIC,DYNAMIC}_{DRAW,READ,COPY}.
Returns
Returns the index of the buffer in the list of all attached vertex buffers

Definition at line 774 of file mesh.h.

◆ attach_vertex_buffer() [2/2]

template<typename T>
unsigned int sgltk::Mesh::attach_vertex_buffer ( const T * vertexdata,
unsigned int number_elements,
GLenum usage = GL_STATIC_DRAW )

Loads data into memory.

Parameters
vertexdataThe data to be loaded into memory
number_elementsNumber of elements
usageA hint as to how the buffer will be accessed. Valid values are GL_{STREAM,STATIC,DYNAMIC}_{DRAW,READ,COPY}.
Returns
Returns the index of the buffer in the list of all attached vertex buffers

Definition at line 765 of file mesh.h.

◆ compute_bounding_box()

template<typename T>
void sgltk::Mesh::compute_bounding_box ( const std::vector< T > & vertexdata,
unsigned int pointer )

Computes the bounding box of the mesh.

Parameters
vertexdataThe vertices of the mesh
pointerThe pointer to the position vector in the vertex structure

Definition at line 872 of file mesh.h.

◆ draw() [1/3]

void Mesh::draw ( GLenum mode)

Renders the mesh using the first index buffer.

Parameters
modeSpecifies the primitive that will be created from vertices

Definition at line 334 of file mesh.cpp.

◆ draw() [2/3]

void Mesh::draw ( GLenum mode,
const glm::mat4 * model_matrix )

Renders the mesh using the first index buffer.

Parameters
modeSpecifies the primitive that will be created from vertices
model_matrixThe model matrix to use (nullptr to use the model_matrix member)

Definition at line 338 of file mesh.cpp.

◆ draw() [3/3]

void Mesh::draw ( GLenum mode,
unsigned int index_buffer,
const glm::mat4 * model_matrix = nullptr )

Renders the mesh.

Parameters
modeSpecifies the primitive that will be created from vertices
index_bufferThe index buffer to use
model_matrixThe model matrix to use (nullptr to use the model_matrix member)

Definition at line 342 of file mesh.cpp.

◆ draw_instanced() [1/2]

void Mesh::draw_instanced ( GLenum mode,
unsigned int index_buffer,
unsigned int num_instances )

Renders the mesh multiple times.

Parameters
modeSpecifies the primitive that will be created from vertices
index_bufferThe index buffer to use
num_instancesNumber of instances to be drawn

Definition at line 437 of file mesh.cpp.

◆ draw_instanced() [2/2]

void Mesh::draw_instanced ( GLenum mode,
unsigned int num_instances )

Renders the mesh multiple times.

Parameters
modeSpecifies the primitive that will be created from vertices
num_instancesNumber of instances to be drawn

Definition at line 433 of file mesh.cpp.

◆ replace_buffer_data() [1/2]

template<typename T>
bool sgltk::Mesh::replace_buffer_data ( unsigned int buffer_index,
const std::vector< T > & data )

Overwrites all data in a vertex buffer.

Parameters
buffer_indexThe index of the buffer to be modified
dataThe data to be loaded into the buffer
Returns
Returns true on success, flase otherwise

Definition at line 794 of file mesh.h.

◆ replace_buffer_data() [2/2]

template<typename T>
bool sgltk::Mesh::replace_buffer_data ( unsigned int buffer_index,
const T * data,
unsigned int number_elements )

Overwrites all data in a vertex buffer.

Parameters
buffer_indexThe index of the buffer to be modified
dataThe data to be loaded into the buffer
number_elementsNumber of elements
Returns
Returns true on success, flase otherwise

Definition at line 785 of file mesh.h.

◆ replace_partial_data() [1/2]

template<typename T>
bool sgltk::Mesh::replace_partial_data ( unsigned int buffer_index,
unsigned int offset,
const std::vector< T > & data )

Modifies the data in a vertex buffer.

Parameters
buffer_indexThe index of the buffer to be modified
offsetThe byte offset into the buffer
dataThe data to be loaded into the buffer
Returns
Returns true on success, flase otherwise

Definition at line 820 of file mesh.h.

◆ replace_partial_data() [2/2]

template<typename T>
bool sgltk::Mesh::replace_partial_data ( unsigned int buffer_index,
unsigned int offset,
const T * data,
unsigned int number_elements )

Modifies the data in a vertex buffer.

Parameters
buffer_indexThe index of the buffer to be modified
offsetThe byte offset into the buffer
dataThe data to be loaded into the buffer
number_elementsNumber of elements
Returns
Returns true on success, flase otherwise

Definition at line 810 of file mesh.h.

◆ set_ambient_color_name()

void Mesh::set_ambient_color_name ( const std::string & name)

Sets the name of the ambient color in the shader.

Parameters
nameThe name of the ambient color component. The name is reset if string is empty.
Note
Default value is "color_ambient"

Definition at line 124 of file mesh.cpp.

◆ set_buffer_vertex_attribute() [1/2]

int Mesh::set_buffer_vertex_attribute ( const std::string & attrib_name,
sgltk::Buffer * buffer,
GLint number_elements,
GLenum type,
GLsizei stride,
const GLvoid * pointer,
unsigned int divisor = 0 )

Sets pointers to vertex attributes.

Parameters
attrib_nameThe attribute name in the shader
bufferThe buffer that contains the attribute
number_elementsNumber of elements
typeElement type
strideMemory offset between vertices
pointerThe offset of the attribute in the vertex structure
divisorDetermines how many instances share the same attribute value. 0 means that every shader instance gets a new value, 1 means every mesh instance gets a new value, 2 means that two instances get the same value and so on.
Returns
Returns 0 on success, -1 if no shader was specified for the mesh, -2 if the vertex attribute could not be found

Definition at line 246 of file mesh.cpp.

◆ set_buffer_vertex_attribute() [2/2]

int Mesh::set_buffer_vertex_attribute ( int attrib_location,
sgltk::Buffer * buffer,
GLint number_elements,
GLenum type,
GLsizei stride,
const GLvoid * pointer,
unsigned int divisor = 0 )

Sets pointers to vertex attributes.

Parameters
attrib_locationThe attribute location in the shader
bufferThe buffer that contains the attribute
number_elementsNumber of elements
typeElement type
strideMemory offset between vertices
pointerThe offset of the attribute in the vertex structure
divisorDetermines how many instances share the same attribute value. 0 means that every shader instance gets a new value, 1 means every mesh instance gets a new value, 2 means that two instances get the same value and so on.
Returns
Returns 0 on success, -1 if no shader was specified for the mesh, -2 if the vertex attribute could not be found

Definition at line 267 of file mesh.cpp.

◆ set_diffuse_color_name()

void Mesh::set_diffuse_color_name ( const std::string & name)

Sets the name of the diffuse color in the shader.

Parameters
nameThe name of the diffuse color component. The name is reset if string is empty.
Note
Default value is "color_diffuse"

Definition at line 131 of file mesh.cpp.

◆ set_model_matrix_name()

void Mesh::set_model_matrix_name ( const std::string & name)

Sets the name of the model matrix in the shader.

Parameters
nameThe name of the model matrix. The name is reset if string is empty.
Note
Default value is "model_matrix"

Definition at line 68 of file mesh.cpp.

◆ set_model_view_matrix_name()

void Mesh::set_model_view_matrix_name ( const std::string & name)

Sets the name of the model-view matrix in the shader.

Parameters
nameThe name of the model-view matrix. The name is reset if string is empty.
Note
Default value is "model_view_matrix"

Definition at line 92 of file mesh.cpp.

◆ set_model_view_proj_name()

void Mesh::set_model_view_proj_name ( const std::string & name)

Sets the name of the model-view-projection matrix in the shader.

Parameters
nameThe name of the model-view-projection matrix. The name is reset if string is empty.
Note
Default value is "model_view_proj_matrix"

Definition at line 108 of file mesh.cpp.

◆ set_normal_matrix_name()

void Mesh::set_normal_matrix_name ( const std::string & name)

Sets the name of the normal matrix in the shader.

Parameters
nameThe name of the normal matrix. The name is reset if string is empty.
Note
Default value is "normal_matrix"

Definition at line 116 of file mesh.cpp.

◆ set_projection_matrix_name()

void Mesh::set_projection_matrix_name ( const std::string & name)

Sets the name of the projection matrix in the shader.

Parameters
nameThe name of the projection matrix. The name is reset if string is empty.
Note
Default value is "proj_matrix"

Definition at line 84 of file mesh.cpp.

◆ set_shininess_name()

void Mesh::set_shininess_name ( const std::string & name)

Sets the name of the shininess of the material in the shader.

Parameters
nameThe name of the shininess component. The name is reset if string is empty.
Note
Default value is "shininess"

Definition at line 145 of file mesh.cpp.

◆ set_shininess_strength_name()

void Mesh::set_shininess_strength_name ( const std::string & name)

Sets the name of the shininess strength of the material in the shader.

Parameters
nameThe name of the shininess strength component. The name is reset if string is empty.
Note
Default value is "shininess_strength"

Definition at line 152 of file mesh.cpp.

◆ set_specular_color_name()

void Mesh::set_specular_color_name ( const std::string & name)

Sets the name of the specular color in the shader.

Parameters
nameThe name of the specular color component. The name is reset if string is empty.
Note
Default value is "color_specular"

Definition at line 138 of file mesh.cpp.

◆ set_transform_feedback_mode()

void Mesh::set_transform_feedback_mode ( GLenum mode)

Sets the output type for transform feedback operations.

Parameters
modeThe output type of the primitives that will be recorded into the buffer objects that are bound for transform feedback

Definition at line 166 of file mesh.cpp.

◆ set_vertex_attribute() [1/2]

int Mesh::set_vertex_attribute ( const std::string & attrib_name,
unsigned int buffer_index,
GLint number_elements,
GLenum type,
GLsizei stride,
const GLvoid * pointer,
unsigned int divisor = 0 )

Sets pointers to vertex attributes.

Parameters
attrib_nameThe attribute name in the shader
buffer_indexThe index of the buffer that contains the attribute
number_elementsNumber of elements
typeElement type
strideMemory offset between vertices
pointerThe offset of the attribute in the vertex structure
divisorDetermines how many instances share the same attribute value. 0 means that every shader instance gets a new value, 1 means every mesh instance gets a new value, 2 means that two instances get the same value and so on.
Returns
Returns 0 on success, -1 if no shader was specified for the mesh, -2 if the vertex attribute could not be found, -3 if the buffer index is invalid

Definition at line 179 of file mesh.cpp.

◆ set_vertex_attribute() [2/2]

int Mesh::set_vertex_attribute ( int attrib_location,
unsigned int buffer_index,
GLint number_elements,
GLenum type,
GLsizei stride,
const GLvoid * pointer,
unsigned int divisor = 0 )

Sets pointers to vertex attributes.

Parameters
attrib_locationThe attribute location in the shader
buffer_indexThe index of the buffer that contains the attribute
number_elementsNumber of elements
typeElement type
strideMemory offset between vertices
pointerThe offset of the attribute in the vertex structure
divisorDetermines how many instances share the same attribute value. 0 means that every shader instance gets a new value, 1 means every mesh instance gets a new value, 2 means that two instances get the same value and so on.
Returns
Returns 0 on success, -1 if no shader was specified for the mesh, -2 if the vertex attribute could not be found, -3 if the buffer index is invalid

Definition at line 200 of file mesh.cpp.

◆ set_view_matrix_name()

void Mesh::set_view_matrix_name ( const std::string & name)

Sets the name of the view matrix in the shader.

Parameters
nameThe name of the view matrix. The name is reset if string is empty.
Note
Default value is "view_matrix"

Definition at line 76 of file mesh.cpp.

◆ set_view_proj_matrix_name()

void Mesh::set_view_proj_matrix_name ( const std::string & name)

Sets the name of the view-projection matrix in the shader.

Parameters
nameThe name of the view-projection matrix. The name is reset if string is empty.
Note
Default value is "view_proj_matrix"

Definition at line 100 of file mesh.cpp.

◆ setup_camera() [1/2]

bool Mesh::setup_camera ( Camera * camera)

Sets up the view and projection matrices that will be used by the mesh.

Parameters
cameraThe camera to use
Returns
Returns true on success, false otherwise

Definition at line 59 of file mesh.cpp.

◆ setup_camera() [2/2]

bool Mesh::setup_camera ( glm::mat4 * view_matrix,
glm::mat4 * projection_matrix )

Sets up the view and projection matrices that will be used by the mesh.

Parameters
view_matrixThe view matrix
projection_matrixThe projection matrix
Returns
Returns true if both pointers are not nullptr, flase otherwise

Definition at line 49 of file mesh.cpp.

◆ setup_shader()

void Mesh::setup_shader ( Shader * shader)

Specifies the shader to use to render the mesh.

Parameters
shaderThe shader to be used to render the mesh

Definition at line 45 of file mesh.cpp.

Member Data Documentation

◆ ambient_color_name

std::string sgltk::Mesh::ambient_color_name

The name of the ambient materiel component.

Definition at line 172 of file mesh.h.

◆ auto_textures

std::vector<std::tuple<std::string, const Texture&, unsigned int> > sgltk::Mesh::auto_textures

Attached textures.

Definition at line 254 of file mesh.h.

◆ bounding_box

std::vector<glm::vec3> sgltk::Mesh::bounding_box

The bounding box.

Definition at line 226 of file mesh.h.

◆ color_ambient

glm::vec4 sgltk::Mesh::color_ambient

The ambient color component of the material.

Definition at line 242 of file mesh.h.

◆ color_diffuse

glm::vec4 sgltk::Mesh::color_diffuse

The diffuse color component of the material.

Definition at line 246 of file mesh.h.

◆ color_specular

glm::vec4 sgltk::Mesh::color_specular

The specular color component of the material.

Definition at line 250 of file mesh.h.

◆ diffuse_color_name

std::string sgltk::Mesh::diffuse_color_name

The name of the diffuse materiel component.

Definition at line 176 of file mesh.h.

◆ model_matrix

glm::mat4 sgltk::Mesh::model_matrix

The model matrix.

Definition at line 230 of file mesh.h.

◆ model_matrix_name

std::string sgltk::Mesh::model_matrix_name

The name of the model matrix in the shader.

Definition at line 193 of file mesh.h.

◆ model_view_matrix_name

std::string sgltk::Mesh::model_view_matrix_name

The name of the model-view matrix in the shader.

Definition at line 205 of file mesh.h.

◆ model_view_projection_matrix_name

std::string sgltk::Mesh::model_view_projection_matrix_name

The name of the model-view-projection matrix in the shader.

Definition at line 213 of file mesh.h.

◆ normal_matrix_name

std::string sgltk::Mesh::normal_matrix_name

The name of the normal matrix in the shader.

Definition at line 217 of file mesh.h.

◆ num_col

unsigned int sgltk::Mesh::num_col

Number of vertex colors.

Definition at line 164 of file mesh.h.

◆ num_uv

unsigned int sgltk::Mesh::num_uv

Number of texture coordinates.

Definition at line 160 of file mesh.h.

◆ num_vertices

unsigned int sgltk::Mesh::num_vertices

Number of vertices.

Definition at line 168 of file mesh.h.

◆ projection_matrix_name

std::string sgltk::Mesh::projection_matrix_name

The name of the projection matrix in the shader.

Definition at line 201 of file mesh.h.

◆ shader

Shader* sgltk::Mesh::shader

The shader being used to draw the mesh.

Definition at line 222 of file mesh.h.

◆ shininess

float sgltk::Mesh::shininess

The shininess of the material.

Definition at line 234 of file mesh.h.

◆ shininess_name

std::string sgltk::Mesh::shininess_name

The name of the specular factor.

Definition at line 184 of file mesh.h.

◆ shininess_strength

float sgltk::Mesh::shininess_strength

The strength of the shininess of the material.

Definition at line 238 of file mesh.h.

◆ shininess_strength_name

std::string sgltk::Mesh::shininess_strength_name

The name of the specular exponent.

Definition at line 188 of file mesh.h.

◆ specular_color_name

std::string sgltk::Mesh::specular_color_name

The name of the specular materiel component.

Definition at line 180 of file mesh.h.

◆ textures

std::vector<std::tuple<std::string, const Texture&, unsigned int> > sgltk::Mesh::textures

Attached user textures.

Definition at line 258 of file mesh.h.

◆ twosided

bool sgltk::Mesh::twosided

Indicates that the mesh should not be drawn using back face culling.

Definition at line 268 of file mesh.h.

◆ view_matrix_name

std::string sgltk::Mesh::view_matrix_name

The name of the view matrix in the shader.

Definition at line 197 of file mesh.h.

◆ view_proj_matrix_name

std::string sgltk::Mesh::view_proj_matrix_name

The name of the view-projection matrix in the shader.

Definition at line 209 of file mesh.h.

◆ wireframe

bool sgltk::Mesh::wireframe

Indicates that the mesh should be drawn as a wireframe.

Definition at line 263 of file mesh.h.


The documentation for this class was generated from the following files: