|
Rendu
A lightweight rendering engine for experimentations
|
Represents a geometric mesh composed of vertices, other attributes and triangles. More...
#include <Mesh.hpp>
Classes | |
| struct | Metrics |
| Information on a geometric mesh. More... | |
Public Types | |
| enum class | Load { Expanded , Points , Indexed } |
| The mesh loading preprocessing mode. More... | |
Public Member Functions | |
| Mesh (const std::string &name) | |
| Mesh (std::istream &in, Mesh::Load mode, const std::string &name) | |
| void | upload () |
| void | clearGeometry () |
| void | clean () |
| BoundingBox | computeBoundingBox () |
| void | computeNormals () |
| void | computeTangentsAndBitangents (bool force) |
| int | saveAsObj (const std::string &path, bool defaultUVs) |
| const std::string & | name () const |
| bool | hadNormals () const |
| bool | hadTexcoords () const |
| bool | hadColors () const |
| const Metrics & | metrics () const |
| Mesh & | operator= (const Mesh &)=delete |
| Mesh (const Mesh &)=delete | |
| Mesh & | operator= (Mesh &&) |
| Mesh (Mesh &&) | |
| ~Mesh () | |
| Buffer & | vertexBuffer () |
| Buffer & | indexBuffer () |
Public Attributes | |
| std::vector< glm::vec3 > | positions |
| The 3D positions. | |
| std::vector< glm::vec3 > | normals |
| The surface normals. | |
| std::vector< glm::vec3 > | tangents |
| The surface tangents. | |
| std::vector< glm::vec3 > | bitangents |
| The surface bitangents. | |
| std::vector< glm::vec3 > | colors |
| The vertex colors. | |
| std::vector< glm::vec2 > | texcoords |
| The texture coordinates. | |
| std::vector< unsigned int > | indices |
| The triangular faces indices. | |
| BoundingBox | bbox |
| The mesh bounding box in model space. | |
| std::unique_ptr< GPUMesh > | gpu |
| The GPU buffers infos (optional). | |
Private Member Functions | |
| void | updateMetrics () |
Private Attributes | |
| Metrics | _metrics |
| Resource stats. | |
| std::string | _name |
| Resource name. | |
Represents a geometric mesh composed of vertices, other attributes and triangles.
For now, material information and elements/groups are not represented. Can store both the CPU and GPU representations. Provides utilities to load and process geometric meshes.
|
strong |
The mesh loading preprocessing mode.
| Enumerator | |
|---|---|
| Expanded | Duplicate vertices for every face. |
| Points | Load the vertices without any connectivity. |
| Indexed | Duplicate only vertices that are shared between faces with attributes with different values. |
| Mesh::Mesh | ( | const std::string & | name | ) |
Default constructor.
| name | the mesh identifier |
| Mesh::Mesh | ( | std::istream & | in, |
| Mesh::Load | mode, | ||
| const std::string & | name | ||
| ) |
Load an .obj file from disk into a mesh structure.
| in | the input string stream from which the geometry will be loaded |
| mode | the preprocessing mode |
| name | the mesh identifier |
|
delete |
Copy constructor (disabled).
|
default |
Move constructor.
|
default |
Destructor
| void Mesh::clean | ( | ) |
Cleanup all data.
| void Mesh::clearGeometry | ( | ) |
Clear CPU geometry data.
| BoundingBox Mesh::computeBoundingBox | ( | ) |
Compute the axi-aligned bounding box of a mesh. Update the internal bbox and returns it.
| void Mesh::computeNormals | ( | ) |
Compute per-vertex normals based on the faces orientation.
| void Mesh::computeTangentsAndBitangents | ( | bool | force | ) |
Compute the tangent and bitangents vectors for each vertex of a mesh.
| force | Compute local tangent frame even if texture coordinates are not available. |
| bool Mesh::hadColors | ( | ) | const |
Did the mesh contained colors initially.
| bool Mesh::hadNormals | ( | ) | const |
Did the mesh contained normals initially.
| bool Mesh::hadTexcoords | ( | ) | const |
Did the mesh contained texture coordinates initially.
| const Mesh::Metrics & Mesh::metrics | ( | ) | const |
| const std::string & Mesh::name | ( | ) | const |
Get the resource name.
Copy assignment operator (disabled).
Move assignment operator .
| int Mesh::saveAsObj | ( | const std::string & | path, |
| bool | defaultUVs | ||
| ) |
Save an OBJ mesh on disk.
| path | the path to the mesh |
| defaultUVs | if the mesh has no UVs, should default ones be used. |
|
private |
Update mesh metrics based on the current CPU content.
| void Mesh::upload | ( | ) |
Send to the GPU.