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< std::shared_ptr< MeshSurface >> &surfaces, const std::string &name="Mesh")
 
 Mesh (const std::string &name="Mesh")
 
const std::shared_ptr< Material > & getSurfaceMaterial (const uint32 surfaceIndex) const
 
void setSurfaceMaterial (uint32 surfaceIndex, const std::shared_ptr< Material > &material)
 
std::vector< std::shared_ptr< MeshSurface > > & getSurfaces ()
 
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 ()
 
auto isUploaded () const
 
void upload ()
 
void buildAABB ()
 
- Public Member Functions inherited from Resource
 Resource (const std::string &name)
 
auto getId () const
 
const auto & getName () const
 
bool operator== (const Resource &other) const
 
bool operator< (const Resource &other) const
 
bool operator> (const Resource &other) const
 
virtual std::shared_ptr< Resource > duplicate () const
 
- Public Member Functions inherited from Object
void connect (const Signal::signal &name, const Signal::Handler &handler)
 
void connect (const Signal::signal &name, const std::function< void ()> &handler)
 
void emit (const Signal::signal &name, void *params=nullptr)
 
virtual std::string toString () const
 
 Object () = default
 
virtual ~Object () = default
 

Protected Attributes

AABB localAABB
 
std::vector< Vertexvertices
 
std::vector< uint32indices
 
std::vector< std::shared_ptr< MeshSurface > > surfaces {}
 
std::unordered_set< std::shared_ptr< Material > > materials {}
 

Friends

bool operator== (const std::shared_ptr< Mesh > &a, const std::shared_ptr< Mesh > &b)
 
bool operator< (const std::shared_ptr< Mesh > &a, const std::shared_ptr< Mesh > &b)
 

Constructor & Destructor Documentation

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

Creates a Mesh from vertices

Parameters
verticesVertices
indicesIndexes of vertices
surfacesSurfaces
nameNode name
Mesh ( const std::string &  name = "Mesh")

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 std::shared_ptr<Material>& getSurfaceMaterial ( const uint32  surfaceIndex) const
inline

Returns the material for a given surface

Parameters
surfaceIndexZero-based index of the surface
std::vector<std::shared_ptr<MeshSurface> >& getSurfaces ( )
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,
const std::shared_ptr< Material > &  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::setSurfaceMaterial instead.

Parameters
surfaceIndexZero-based index of the Surface
materialNew material for the Surface
void upload ( )

Friends And Related Function Documentation

bool operator< ( const std::shared_ptr< Mesh > &  a,
const std::shared_ptr< Mesh > &  b 
)
friend
bool operator== ( const std::shared_ptr< Mesh > &  a,
const std::shared_ptr< Mesh > &  b 
)
friend
friend class Window
friend

Member Data Documentation

std::vector<uint32> indices
protected
AABB localAABB
protected
std::unordered_set<std::shared_ptr<Material> > materials {}
protected
std::vector<std::shared_ptr<MeshSurface> > surfaces {}
protected
std::vector<Vertex> vertices
protected