|
lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
|
Represents a 3D mesh with associated vertex array and shader. More...
#include <mesh.hpp>
Public Member Functions | |
| Mesh (const std::vector< Vertex > &vert, const std::vector< unsigned int > &indices, std::shared_ptr< renderer::Shader > shader) | |
| Constructor for the Mesh class. | |
| Mesh (std::shared_ptr< renderer::VertexArray > vao, std::shared_ptr< renderer::Shader > shader, unsigned int idx_count) | |
| Constructor for the Mesh class. | |
| ~Mesh ()=default | |
| Destructor for the Mesh class. | |
| void | bind () const |
| Binds the mesh for rendering. | |
| void | unbind () const |
| Unbinds the mesh after rendering. | |
| void | render () const |
| Renders the mesh. | |
| std::shared_ptr< renderer::VertexArray > | get_vertex_array () const |
| Getter for vertex array. | |
| std::shared_ptr< renderer::Shader > | get_shader () const |
| Getter for shader. | |
| void | set_shader (std::shared_ptr< renderer::Shader > shader) |
| Setter for shader. | |
| unsigned int | get_index_count () const |
| Getter for index count. | |
| const std::vector< Vertex > & | get_vertices () const |
| Getter for vertices. | |
| const std::vector< unsigned int > & | get_indices () const |
| Getter for indices. | |
| bool | has_vert_data () const |
| Check if the mesh has vertex data. | |
| std::shared_ptr< Material > | get_material () const |
| Retrieve the material associated with the mesh. | |
| void | set_material (std::shared_ptr< Material > material) |
| Sets the material associated to the mesh. | |
| const AABB & | get_bounding_box () const |
| Getter for bounding box. | |
| const BoundingSphere & | get_bounding_sphere () const |
| Getter for bounding sphere. | |
Static Public Member Functions | |
| static std::shared_ptr< Mesh > | create_cube (std::shared_ptr< renderer::Shader > shader, unsigned int subdivs=1) |
| Creates a cube mesh. | |
| static std::shared_ptr< Mesh > | create_quad (std::shared_ptr< renderer::Shader > shader, float width=1.0f, float height=1.0f) |
| Creates a quad mesh. | |
| static std::shared_ptr< Mesh > | create_sphere (std::shared_ptr< renderer::Shader > shader, float radius=0.5f, unsigned int lonsegs=32, unsigned int latsegs=32) |
| Creates a sphere mesh. | |
Represents a 3D mesh with associated vertex array and shader.
The Mesh class encapsulates a vertex array and a shader program used for rendering 3D meshes. It provides access to the underlying vertex array and shader, facilitating the rendering process in a graphics application.
| lmgl::scene::Mesh::Mesh | ( | const std::vector< Vertex > & | vert, |
| const std::vector< unsigned int > & | indices, | ||
| std::shared_ptr< renderer::Shader > | shader ) |
| lmgl::scene::Mesh::Mesh | ( | std::shared_ptr< renderer::VertexArray > | vao, |
| std::shared_ptr< renderer::Shader > | shader, | ||
| unsigned int | idx_count ) |
| void lmgl::scene::Mesh::bind | ( | ) | const |
Binds the mesh for rendering.
Prepares the mesh for rendering by binding the vertex array and shader.
|
static |
Creates a cube mesh.
Generates a cube mesh with the specified shader and subdivisions.
| shader | Shared pointer to the Shader object. |
| subdivs | Number of subdivisions for the cube (default is 1). |
|
static |
Creates a quad mesh.
Generates a quad mesh with the specified shader, width, and height.
| shader | Shared pointer to the Shader object. |
| width | Width of the quad (default is 1.0f). |
| height | Height of the quad (default is 1.0f). |
|
static |
Creates a sphere mesh.
Generates a sphere mesh with the specified shader, radius, and segmentation.
| shader | Shared pointer to the Shader object. |
| radius | Radius of the sphere (default is 0.5f). |
| lonsegs | Number of longitudinal segments (default is 32). |
| latsegs | Number of latitudinal segments (default is 32). |
|
inline |
Getter for bounding box.
Provides access to the axis-aligned bounding box of the mesh.
|
inline |
Getter for bounding sphere.
Provides access to the bounding sphere of the mesh.
|
inline |
Getter for index count.
Provides the number of indices in the mesh.
|
inline |
Getter for indices.
Provides access to the vector of indices defining the mesh geometry.
|
inline |
Retrieve the material associated with the mesh.
|
inline |
Getter for shader.
Provides access to the shader associated with the mesh.
|
inline |
Getter for vertex array.
Provides access to the vertex array associated with the mesh.
|
inline |
Getter for vertices.
Provides access to the vector of vertices defining the mesh geometry.
|
inline |
Check if the mesh has vertex data.
Determines if the mesh contains valid vertex and index data.
| void lmgl::scene::Mesh::render | ( | ) | const |
Renders the mesh.
Issues the draw call to render the mesh using the associated vertex array and shader.
|
inline |
Sets the material associated to the mesh.
| material | The new material to set. |
|
inline |
Setter for shader.
Sets the shader associated with the mesh.
| shader | Shared pointer to the Shader object. |
| void lmgl::scene::Mesh::unbind | ( | ) | const |
Unbinds the mesh after rendering.
Cleans up after rendering by unbinding the vertex array and shader.