Lysa  0.0
Lysa 3D Engine
TriangleMesh Class Reference

Detailed Description

A procedurally generated flat triangle in the XY plane, centered at the origin. The surface normal points toward +Z. The apex is at the top (+Y), the base spans the bottom (-Y). UV (0.5,0) is at the apex, (0,1) at the bottom-left corner, (1,1) at the bottom-right corner.

+ Inheritance diagram for TriangleMesh:

Public Member Functions

 TriangleMesh (float width, float height, unique_id material, MeshAlignment alignment=MeshAlignment::CENTER, float xOffset=0.f, float yOffset=0.f, const std::string &name="TriangleMesh")
 
- Public Member Functions inherited from Mesh
 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 getMeshIndex () const
 
auto getVerticesIndex () const
 
auto getIndicesIndex () const
 
auto getSurfacesIndex () const
 
auto & getMaterials ()
 
const auto & getMaterials () 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
 

Additional Inherited Members

- Public Attributes inherited from ManagedResource
uint32 refCounter {0}
 
- Public Attributes inherited from Resource
unique_id id {INVALID_ID}
 
- Protected Attributes inherited from Mesh
const std::string name
 
AABB localAABB
 
std::vector< Vertexvertices
 
std::vector< uint32indices
 
std::vector< MeshSurfacesurfaces {}
 
std::unordered_set< unique_idmaterials {}
 

Constructor & Destructor Documentation

TriangleMesh ( float  width,
float  height,
unique_id  material,
MeshAlignment  alignment = MeshAlignment::CENTER,
float  xOffset = 0.f,
float  yOffset = 0.f,
const std::string &  name = "TriangleMesh" 
)

Creates a TriangleMesh in the XY plane.

Parameters
widthWidth of the triangle base along the X axis (world units)
heightHeight of the triangle along the Y axis (world units)
materialMaterial to apply to the triangle surface
alignmentCENTER: apex at horizontal center; LEFT: left base edge at origin
xOffsetHorizontal offset applied to all vertices
yOffsetVertical offset applied to all vertices
nameResource name