Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Mesh Class Reference

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 Metricsmetrics () const
 
Meshoperator= (const Mesh &)=delete
 
 Mesh (const Mesh &)=delete
 
Meshoperator= (Mesh &&)
 
 Mesh (Mesh &&)
 
 ~Mesh ()
 
BuffervertexBuffer ()
 
BufferindexBuffer ()
 

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< GPUMeshgpu
 The GPU buffers infos (optional).
 

Private Member Functions

void updateMetrics ()
 

Private Attributes

Metrics _metrics
 Resource stats.
 
std::string _name
 Resource name.
 

Detailed Description

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.

Member Enumeration Documentation

◆ Load

enum class Mesh::Load
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.

Constructor & Destructor Documentation

◆ Mesh() [1/4]

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

Default constructor.

Parameters
namethe mesh identifier

◆ Mesh() [2/4]

Mesh::Mesh ( std::istream &  in,
Mesh::Load  mode,
const std::string &  name 
)

Load an .obj file from disk into a mesh structure.

Parameters
inthe input string stream from which the geometry will be loaded
modethe preprocessing mode
namethe mesh identifier

◆ Mesh() [3/4]

Mesh::Mesh ( const Mesh )
delete

Copy constructor (disabled).

◆ Mesh() [4/4]

Mesh::Mesh ( Mesh &&  )
default

Move constructor.

◆ ~Mesh()

Mesh::~Mesh ( )
default

Destructor

Member Function Documentation

◆ clean()

void Mesh::clean ( )

Cleanup all data.

◆ clearGeometry()

void Mesh::clearGeometry ( )

Clear CPU geometry data.

◆ computeBoundingBox()

BoundingBox Mesh::computeBoundingBox ( )

Compute the axi-aligned bounding box of a mesh. Update the internal bbox and returns it.

Returns
the bounding box

◆ computeNormals()

void Mesh::computeNormals ( )

Compute per-vertex normals based on the faces orientation.

◆ computeTangentsAndBitangents()

void Mesh::computeTangentsAndBitangents ( bool  force)

Compute the tangent and bitangents vectors for each vertex of a mesh.

Parameters
forceCompute local tangent frame even if texture coordinates are not available.

◆ hadColors()

bool Mesh::hadColors ( ) const

Did the mesh contained colors initially.

Returns
true if it did

◆ hadNormals()

bool Mesh::hadNormals ( ) const

Did the mesh contained normals initially.

Returns
true if it did

◆ hadTexcoords()

bool Mesh::hadTexcoords ( ) const

Did the mesh contained texture coordinates initially.

Returns
true if it did

◆ indexBuffer()

Buffer & Mesh::indexBuffer ( )
Returns
a reference to the GPU vertex buffer if it exists

◆ metrics()

const Mesh::Metrics & Mesh::metrics ( ) const
Returns
the mesh current metrics (vertex count,...)

◆ name()

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

Get the resource name.

Returns
the name.

◆ operator=() [1/2]

Mesh & Mesh::operator= ( const Mesh )
delete

Copy assignment operator (disabled).

Returns
a reference to the object assigned to

◆ operator=() [2/2]

Mesh & Mesh::operator= ( Mesh &&  )
default

Move assignment operator .

Returns
a reference to the object assigned to

◆ saveAsObj()

int Mesh::saveAsObj ( const std::string &  path,
bool  defaultUVs 
)

Save an OBJ mesh on disk.

Parameters
paththe path to the mesh
defaultUVsif the mesh has no UVs, should default ones be used.
Returns
a success/error flag

◆ updateMetrics()

void Mesh::updateMetrics ( )
private

Update mesh metrics based on the current CPU content.

◆ upload()

void Mesh::upload ( )

Send to the GPU.

◆ vertexBuffer()

Buffer & Mesh::vertexBuffer ( )
Returns
a reference to the GPU vertex buffer if it exists

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