Mesh Class
Representative of a renderable 3D mesh. More...
Declaration
Derived Classes
| class | OpenGLMesh |
|
Representative of an OpenGLMesh. This class manages the OpenGL Vertex Array Object (VAO), the Vertex Buffer Object (VBO) and Element Buffer Object (EBO) handles. The raw mesh data is uploaded to the GPU, preparing it for subsequent rendering commands / draw calls. More... | |
Public Constructors Index
| Mesh (std::shared_ptr< const std::vector< Vertex > > vertices, std::shared_ptr< const std::vector< unsigned int > > indices, std::shared_ptr< const helios::rendering::mesh::MeshConfig > meshConfig) | |
| Mesh (const helios::rendering::asset::shape::Shape &shape, std::shared_ptr< const helios::rendering::mesh::MeshConfig > meshConfig) | |
|
Creates a new Mesh instance from the specified Shape. More... | |
Protected Constructors Index
| Mesh ()=default | |
Public Destructor Index
| ~Mesh ()=default | |
Public Member Functions Index
| unsigned int | indexCount () const noexcept |
| const std::vector< Vertex > & | vertices () const noexcept |
|
Returns a const reference to the underlying vertices. The returned data is guaranteed to be a valid reference to existing data. More... | |
| const std::vector< unsigned int > & | indices () const noexcept |
|
Returns a const reference to the underlying indices. The returned data is guaranteed to be a valid reference to existing data. More... | |
| const helios::rendering::mesh::MeshConfig & | meshConfig () const noexcept |
|
Returns a const reference to MeshConfig used with this Mesh. The returned MeshConfig is guaranteed to be a valid reference to existing data. More... | |
| const helios::math::aabbf & | aabb () const noexcept |
|
Retrieves the axis-aligned bounding box (AABB) of the mesh. More... | |
Protected Member Functions Index
| void | init ()=0 |
|
Initializes the Mesh by setting up vertex attributes and buffers with the underlying GL API. This method should be called _once_ by the derived class before using this Mesh in a rendering pass. More... | |
Protected Member Attributes Index
| bool | needsUpdate_ = true |
|
Flag indicating whether the mesh requires updates to its computed data. More... | |
| helios::math::aabbf | aabb_ {} |
|
Represents the axis-aligned bounding box (AABB) for the mesh. More... | |
| std::shared_ptr< const std::vector< Vertex > > | vertices_ = nullptr |
|
Shared pointer to the raw, immutable vertices. More... | |
| std::shared_ptr< const std::vector< unsigned int > > | indices_ = nullptr |
|
Shared pointer to the raw, immutable indices. More... | |
| std::shared_ptr< const helios::rendering::mesh::MeshConfig > | meshConfig_ |
|
Shared pointer to the MeshConfig used with this Mesh. More... | |
Protected Static Attributes Index
| static const helios::util::log::Logger & | logger_ = ... |
Description
Representative of a renderable 3D mesh.
A Mesh instance contains vertex data and indices provided by geometric shapes. Meshes contain references to immutable, shared vertex data and indices. Concrete implementations will handle resource management.
- See Also
[Gre19, 631]
Definition at line 37 of file Mesh.ixx.
Public Constructors
Mesh()
| inline explicit |
Creates a new Mesh instance.
- Parameters
-
vertices A shared_ptr to a vector of Vertex.
indices A shared_ptr to a vector of indices.
meshConfig A shared_ptr to the MeshConfig used with this Mesh.
- Exceptions
-
std::invalid_argument if either "vertices", "indices" or meshConfig is a null shared_ptr
Definition at line 117 of file Mesh.ixx.
References indices, indices_, logger_, meshConfig, meshConfig_, vertices and vertices_.
Mesh()
| inline explicit |
Creates a new Mesh instance from the specified Shape.
- Parameters
-
shape A const reference to the Shape.
meshConfig A shared_ptr to the MeshConfig used with this Mesh.
- Exceptions
-
std::invalid_argument if meshConfig is a null shared_ptr, or if the shape contained null data.
Definition at line 141 of file Mesh.ixx.
References indices, indices_, logger_, meshConfig, meshConfig_, vertices and vertices_.
Protected Constructors
Mesh()
| protected default |
Definition at line 41 of file Mesh.ixx.
Referenced by helios::ext::opengl::rendering::model::OpenGLMesh::OpenGLMesh and helios::ext::opengl::rendering::model::OpenGLMesh::OpenGLMesh.
Public Member Functions
aabb()
| inline nodiscard noexcept |
Retrieves the axis-aligned bounding box (AABB) of the mesh.
The method calculates and returns the AABB of the mesh, which encloses the mesh's vertices. If the mesh requires an update to its bounding box, this method recomputes the bounds based on the vertex positions and caches the result for future calls. The returned AABB represents the minimal rectangle in 3D space that contains all the vertices of the mesh.
- Returns
Reference to the computed axis-aligned bounding box.
Definition at line 207 of file Mesh.ixx.
References aabb_, needsUpdate_ and vertices_.
indexCount()
| inline nodiscard noexcept |
indices()
| inline nodiscard noexcept |
Returns a const reference to the underlying indices. The returned data is guaranteed to be a valid reference to existing data.
- Returns
A const ref to the vector of indices.
Definition at line 181 of file Mesh.ixx.
Reference indices_.
Referenced by Mesh, Mesh and helios::ext::opengl::rendering::model::OpenGLMesh::OpenGLMesh.
meshConfig()
| inline nodiscard noexcept |
Returns a const reference to MeshConfig used with this Mesh. The returned MeshConfig is guaranteed to be a valid reference to existing data.
- Returns
The MeshConfig used with this Mesh.
Definition at line 191 of file Mesh.ixx.
Reference meshConfig_.
Referenced by Mesh, Mesh, helios::ext::opengl::rendering::model::OpenGLMesh::OpenGLMesh and helios::ext::opengl::rendering::model::OpenGLMesh::OpenGLMesh.
vertices()
| inline nodiscard noexcept |
Returns a const reference to the underlying vertices. The returned data is guaranteed to be a valid reference to existing data.
- Returns
A const ref to the vector of Vertex.
Definition at line 171 of file Mesh.ixx.
Reference vertices_.
Referenced by Mesh, Mesh and helios::ext::opengl::rendering::model::OpenGLMesh::OpenGLMesh.
Protected Member Functions
init()
| protected |
Initializes the Mesh by setting up vertex attributes and buffers with the underlying GL API. This method should be called _once_ by the derived class before using this Mesh in a rendering pass.
- Todo
-
std::shared_ptr<const std::vector<Texture>> textures_;
- Exceptions
-
std::runtime_error if the Mesh could not be initialized.
Protected Member Attributes
aabb_
| protected mutable |
Represents the axis-aligned bounding box (AABB) for the mesh.
This member variable stores the computed or cached AABB for the mesh in 3D space. The AABB is a minimal bounding box aligned with the coordinate axes that encloses all the vertices of the mesh. It is marked mutable to allow updates during read-only operations, such as recalculating bounds as vertex positions are modified or updated dynamically.
- See Also
Definition at line 65 of file Mesh.ixx.
Referenced by aabb.
indices_
| protected |
Shared pointer to the raw, immutable indices.
Definition at line 75 of file Mesh.ixx.
Referenced by indexCount, indices, helios::ext::opengl::rendering::model::OpenGLMesh::init, Mesh, Mesh, helios::ext::opengl::rendering::model::OpenGLMesh::OpenGLMesh and helios::ext::opengl::rendering::model::OpenGLMesh::OpenGLMesh.
meshConfig_
| protected |
Shared pointer to the MeshConfig used with this Mesh.
Definition at line 80 of file Mesh.ixx.
Referenced by Mesh, Mesh, meshConfig, helios::ext::opengl::rendering::model::OpenGLMesh::OpenGLMesh and helios::ext::opengl::rendering::model::OpenGLMesh::OpenGLMesh.
needsUpdate_
| protected mutable |
Flag indicating whether the mesh requires updates to its computed data.
This variable is used to track whether the mesh's derived properties, such as its axis-aligned bounding box (AABB), are outdated and need to be recalculated. It is marked as mutable to allow modification within const member functions.
Definition at line 51 of file Mesh.ixx.
Referenced by aabb.
vertices_
| protected |
Shared pointer to the raw, immutable vertices.
Definition at line 70 of file Mesh.ixx.
Referenced by aabb, helios::ext::opengl::rendering::model::OpenGLMesh::init, Mesh, Mesh, helios::ext::opengl::rendering::model::OpenGLMesh::OpenGLMesh, helios::ext::opengl::rendering::model::OpenGLMesh::OpenGLMesh and vertices.
Protected Static Attributes
logger_
| protected static |
Shared logger instance for all Mesh objects.
- Initialiser
Definition at line 100 of file Mesh.ixx.
Referenced by Mesh, Mesh, helios::ext::opengl::rendering::model::OpenGLMesh::OpenGLMesh and helios::ext::opengl::rendering::model::OpenGLMesh::OpenGLMesh.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.