65 Vertex(
const glm::vec3 &pos = glm::vec3(0.0f),
const glm::vec3 &norm = glm::vec3(0.0f, 1.0f, 0.0f),
66 const glm::vec4 &col = glm::vec4(1.0f),
const glm::vec2 &uv = glm::vec2(0.0f))
88 Mesh(
const std::vector<Vertex> &vert,
const std::vector<unsigned int> &indices,
89 std::shared_ptr<renderer::Shader> shader);
100 Mesh(std::shared_ptr<renderer::VertexArray> vao, std::shared_ptr<renderer::Shader> shader,
unsigned int idx_count);
133 inline std::shared_ptr<renderer::VertexArray>
get_vertex_array()
const {
return m_vertex_array; }
142 inline std::shared_ptr<renderer::Shader>
get_shader()
const {
return m_shader; }
151 inline void set_shader(std::shared_ptr<renderer::Shader> shader) { m_shader = shader; }
169 inline const std::vector<Vertex> &
get_vertices()
const {
return m_vertices; }
178 inline const std::vector<unsigned int> &
get_indices()
const {
return m_indices; }
187 inline bool has_vert_data()
const {
return !m_vertices.empty() && !m_indices.empty(); }
194 inline std::shared_ptr<Material>
get_material()
const {
return m_material; }
201 inline void set_material(std::shared_ptr<Material> material) { m_material = material; }
232 static std::shared_ptr<Mesh>
create_cube(std::shared_ptr<renderer::Shader> shader,
unsigned int subdivs = 1);
244 static std::shared_ptr<Mesh>
create_quad(std::shared_ptr<renderer::Shader> shader,
float width = 1.0f,
245 float height = 1.0f);
258 static std::shared_ptr<Mesh>
create_sphere(std::shared_ptr<renderer::Shader> shader,
float radius = 0.5f,
259 unsigned int lonsegs = 32,
unsigned int latsegs = 32);
263 std::shared_ptr<Material> m_material;
266 std::shared_ptr<renderer::VertexArray> m_vertex_array;
269 std::shared_ptr<renderer::Shader> m_shader;
272 unsigned int m_index_count;
275 std::vector<Vertex> m_vertices;
278 std::vector<unsigned int> m_indices;
298 void calculate_bounds();
const std::vector< Vertex > & get_vertices() const
Getter for vertices.
Definition mesh.hpp:169
void unbind() const
Unbinds the mesh after rendering.
Definition mesh.cpp:60
const BoundingSphere & get_bounding_sphere() const
Getter for bounding sphere.
Definition mesh.hpp:219
bool has_vert_data() const
Check if the mesh has vertex data.
Definition mesh.hpp:187
void set_material(std::shared_ptr< Material > material)
Sets the material associated to the mesh.
Definition mesh.hpp:201
~Mesh()=default
Destructor for the Mesh class.
void set_shader(std::shared_ptr< renderer::Shader > shader)
Setter for shader.
Definition mesh.hpp:151
std::shared_ptr< Material > get_material() const
Retrieve the material associated with the mesh.
Definition mesh.hpp:194
void bind() const
Binds the mesh for rendering.
Definition mesh.cpp:53
const AABB & get_bounding_box() const
Getter for bounding box.
Definition mesh.hpp:210
void render() const
Renders the mesh.
Definition mesh.cpp:67
std::shared_ptr< renderer::VertexArray > get_vertex_array() const
Getter for vertex array.
Definition mesh.hpp:133
static std::shared_ptr< Mesh > create_cube(std::shared_ptr< renderer::Shader > shader, unsigned int subdivs=1)
Creates a cube mesh.
Definition mesh.cpp:69
Mesh(const std::vector< Vertex > &vert, const std::vector< unsigned int > &indices, std::shared_ptr< renderer::Shader > shader)
Constructor for the Mesh class.
Definition mesh.cpp:16
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.
Definition mesh.cpp:123
std::shared_ptr< renderer::Shader > get_shader() const
Getter for shader.
Definition mesh.hpp:142
const std::vector< unsigned int > & get_indices() const
Getter for indices.
Definition mesh.hpp:178
unsigned int get_index_count() const
Getter for index count.
Definition mesh.hpp:160
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.
Definition mesh.cpp:111
Defines frustum and bounding volume structures for 3D scene management.
Definition of the Material class for 3D rendering.
Namespace for scene-related classes and functions.
Definition camera.cpp:7
Forward declarations for Assimp Material structure.
Definition model_loader.cpp:12
Declaration of the Shader class for managing shader programs in OpenGL.
Axis-Aligned Bounding Box (AABB) structure.
Definition frustum.hpp:27
Bounding Sphere structure.
Definition frustum.hpp:105
glm::vec2 uvs
Texture coordinates (UVs) of the vertex.
Definition mesh.hpp:46
glm::vec3 position
Position of the vertex in 3D space.
Definition mesh.hpp:37
Vertex(const glm::vec3 &pos=glm::vec3(0.0f), const glm::vec3 &norm=glm::vec3(0.0f, 1.0f, 0.0f), const glm::vec4 &col=glm::vec4(1.0f), const glm::vec2 &uv=glm::vec2(0.0f))
Constructor for the Vertex struct.
Definition mesh.hpp:65
glm::vec3 normal
Normal vector at the vertex.
Definition mesh.hpp:40
glm::vec3 bitangent
Texture bitangetn.
Definition mesh.hpp:52
glm::vec4 color
Color of the vertex.
Definition mesh.hpp:43
glm::vec3 tangent
Texture tangent.
Definition mesh.hpp:49
Declaration of the VertexArray class for managing Vertex Array Objects (VAOs) in OpenGL.