Lysa  0.0
Lysa 3D Engine
Mesh Class Reference

Detailed Description

A mesh composed by multiple Surface and an indexes collection of Vertex

+ Inheritance diagram for Mesh:

Public Member Functions

 Mesh (const std::vector< Vertex > &vertices, const std::vector< uint32 > &indices, const std::vector< MeshSurface > &surfaces, const std::string &name)
 
 Mesh (const std::string &name)
 
 ~Mesh () override
 
unique_id getSurfaceMaterial (const uint32 surfaceIndex) const
 
void setSurfaceMaterial (uint32 surfaceIndex, unique_id material)
 
std::vector< MeshSurface > & getSurfaces ()
 
const std::vector< MeshSurface > & getSurfaces () const
 
std::vector< Vertex > & getVertices ()
 
std::vector< uint32 > & getIndices ()
 
const std::vector< Vertex > & getVertices () const
 
const std::vector< uint32 > & getIndices () const
 
const AABBgetAABB () const
 
bool operator== (const Mesh &other) const
 
auto getVerticesIndex () const
 
auto getIndicesIndex () const
 
auto getSurfacesIndex () const
 
auto & getMaterials ()
 
const auto & getMaterials () const
 
auto isUploaded () const
 
void buildAABB ()
 
constexpr const std::string & getName () const
 
- Public Member Functions inherited from ManagedResource
 ManagedResource () = default
 
 ManagedResource (UniqueResource &) = delete
 
ManagedResource & operator= (ManagedResource &) = delete
 
- Public Member Functions inherited from Resource
bool operator== (const Resource &other) const
 
 Resource () = default
 
 Resource (const unique_id id)
 
virtual ~Resource () = default
 

Protected Attributes

const std::string name
 
AABB localAABB
 
std::vector< Vertexvertices
 
std::vector< uint32indices
 
std::vector< MeshSurfacesurfaces {}
 
std::unordered_set< unique_idmaterials {}
 

Additional Inherited Members

- Public Attributes inherited from ManagedResource
uint32 refCounter {0}
 
- Public Attributes inherited from Resource
unique_id id {INVALID_ID}
 

Constructor & Destructor Documentation

Mesh ( const std::vector< Vertex > &  vertices,
const std::vector< uint32 > &  indices,
const std::vector< MeshSurface > &  surfaces,
const std::string &  name 
)

Creates a Mesh from vertices

Parameters
verticesVertices
indicesIndexes of vertices
surfacesSurfaces
name
Mesh ( const std::string &  name)
inline
~Mesh ( )
override

Member Function Documentation

void buildAABB ( )
const AABB& getAABB ( ) const
inline

Returns the local space axis aligned bounding box

std::vector<uint32>& getIndices ( )
inline

Return all the vertices indexes

const std::vector<uint32>& getIndices ( ) const
inline

Return all the vertices indexes

auto getIndicesIndex ( ) const
inline
auto& getMaterials ( )
inline
const auto& getMaterials ( ) const
inline
constexpr const std::string& getName ( ) const
inlineconstexpr
unique_id getSurfaceMaterial ( const uint32  surfaceIndex) const
inline

Returns the material for a given surface

Parameters
surfaceIndexZero-based index of the surface
std::vector<MeshSurface>& getSurfaces ( )
inline

Returns all the Surfaces

const std::vector<MeshSurface>& getSurfaces ( ) const
inline

Returns all the Surfaces

auto getSurfacesIndex ( ) const
inline
std::vector<Vertex>& getVertices ( )
inline

Returns all the vertices

const std::vector<Vertex>& getVertices ( ) const
inline

Returns all the vertices

auto getVerticesIndex ( ) const
inline
auto isUploaded ( ) const
inline
bool operator== ( const Mesh &  other) const
void setSurfaceMaterial ( uint32  surfaceIndex,
unique_id  material 
)

Changes the material of a given surface. Warning: this will update the data in memory only but not the node in the scene. If the material needs a different pipeline, the change will not appear. Use MeshInstance::setSurfaceMaterialOverride instead.

Parameters
surfaceIndexZero-based index of the Surface
materialNew material for the Surface

Friends And Related Function Documentation

friend class MeshManager
friend

Member Data Documentation

std::vector<uint32> indices
protected
AABB localAABB
protected
std::unordered_set<unique_id> materials {}
protected
const std::string name
protected
std::vector<MeshSurface> surfaces {}
protected
std::vector<Vertex> vertices
protected