3D Graphics Engine for ESP32
 
Loading...
Searching...
No Matches
Ragot::Mesh Class Referenceabstract

Represents a 3D mesh in the Ragot engine. More...

#include <Mesh.hpp>

Inheritance diagram for Ragot::Mesh:
Inheritance graph
Collaboration diagram for Ragot::Mesh:
Collaboration graph

Public Member Functions

 Mesh ()=delete
 Construct a new Mesh object (deleted constructor).
 
virtual ~Mesh ()=default
 Default virtual destructor for the Mesh class.
 
 Mesh (mesh_info_t &mesh_info)
 Construct a new Mesh object with mesh information.
 
virtual void generate_vertices ()=0
 Generate vertices for the mesh.
 
virtual void generate_faces ()=0
 Generate faces for the mesh.
 
const std::vector< glm::fvec4 > & get_vertices () const
 Get the vertices object.
 
const std::vector< face_t > & get_faces () const
 Get the faces object.
 
const size_t get_total_vertices () const
 Get the total vertices object.
 
size_t get_total_vertices ()
 Get the total vertices object.
 
void recalculate ()
 Recalculate the mesh vertices and faces.
 
void apply_transform_to_vertices ()
 Apply the current transformation to the vertices of the mesh. This method applies the transformation matrix obtained from the Transform class to each vertex in the mesh. This is useful for updating the mesh vertices after any transformation has been applied, such as translation, rotation, or scaling. It modifies the vertices in place, transforming them according to the current transformation matrix.
 
void set_color (uint16_t new_color)
 Set the color of the mesh.
 
uint16_t get_color () const
 Get the color of the mesh.
 
- Public Member Functions inherited from Ragot::Component
 Component ()=default
 Default constructor for the Component class.
 
virtual ~Component ()=default
 Default virtual destructor for the Component class.
 
 Component (const Component &)=delete
 Deleted copy constructor for the Component class.
 
 Component (const Component &&)=delete
 Deleted move constructor for the Component class.
 
Componentoperator= (const Component &)=delete
 Deleted assignment operator for the Component class.
 
Componentoperator= (const Component &&)=delete
 Deleted move assignment operator for the Component class.
 
void add_component (std::shared_ptr< Component > component)
 Adds a component to the collection.
 
void remove_component (std::shared_ptr< Component > component)
 Removes a component from the collection.
 
const std::vector< std::shared_ptr< Component > > get_components () const
 Gets the collection of components.
 
- Public Member Functions inherited from Ragot::Node
 Node ()=default
 Default constructor for Node. Initializes an empty node with no parent and no children.
 
virtual ~Node ()=default
 Default destructor for Node. Cleans up the node and its children.
 
 Node (const Node &)=delete
 Deleted copy constructor for Node. Prevents copying of Node instances.
 
 Node (const Node &&)=delete
 Deleted move constructor for Node. Prevents moving of Node instances.
 
Nodeoperator= (const Node &)=delete
 Deleted assignment operator for Node. Prevents assignment of Node instances.
 
Nodeoperator= (const Node &&)=delete
 Deleted move assignment operator for Node. Prevents moving of Node instances.
 
void add_child (std::shared_ptr< Node > child)
 Get the parent node.
 
void remove_child (std::shared_ptr< Node > child)
 Remove a child node.
 
const std::vector< std::shared_ptr< Node > > & get_children () const
 Get the parent node.
 
mat4 get_transform_matrix () override
 Get the transform matrix object.
 
- Public Member Functions inherited from Ragot::Transform
 Transform ()
 Default constructor for the Transform class.
 
virtual ~Transform ()=default
 Virtual destructor for the Transform class.
 
void set_position (const vec3 &pos)
 Sets the position of the object.
 
vec3 get_position () const
 Gets the current position of the object.
 
void set_rotation (const vec3 &rot)
 Moves the object by a specified vector.
 
vec3 get_rotation () const
 Gets the current rotation of the object.
 
void rotate (const float angle, const vec3 &axis)
 Rotates the object by a specified angle around a given axis.
 
void set_scale (const vec3 &scale)
 Sets the scale of the object.
 
vec3 get_scale () const
 Sets the scale of the object uniformly.
 
bool is_dirty () const
 Checks if the transformation matrix is dirty (needs recalculation).
 

Protected Attributes

mesh_info_t mesh_info
 Information about the mesh, including coordinates and rendering type.
 
uint16_t color = 0xFFFF
 Color of the mesh, default is white (0xFFFF).
 
std::vector< glm::fvec4 > vertices
 Vector of vertices representing the mesh in 3D space.
 
std::vector< face_tfaces
 Vector of faces representing the mesh, each face can be a triangle or a quad.
 
int slices = 16
 Number of slices for generating the mesh, default is 16.
 
- Protected Attributes inherited from Ragot::Component
std::vector< std::shared_ptr< Component > > components
 Collection of components managed by this Component instance.
 
- Protected Attributes inherited from Ragot::Node
std::vector< std::shared_ptr< Node > > children
 List of child nodes.
 
Nodeparent = nullptr
 Pointer to the parent node.
 
- Protected Attributes inherited from Ragot::Transform
vec3 position
 The position of the object in 3D space.
 
vec3 rotation
 The rotation of the object in degrees around each axis (x, y, z).
 
vec3 scale
 The scale of the object in 3D space, default is (1, 1, 1).
 
bool dirty = true
 Flag indicating whether the transformation matrix needs to be recalculated.
 

Detailed Description

Represents a 3D mesh in the Ragot engine.

The Mesh class is a base class for creating 3D meshes with vertices and faces. It provides methods to generate vertices and faces, apply transformations, and manage mesh information. The class also includes methods for setting and getting the color of the mesh.

Constructor & Destructor Documentation

◆ Mesh() [1/2]

Ragot::Mesh::Mesh ( )
delete

Construct a new Mesh object (deleted constructor).

Here is the caller graph for this function:

◆ ~Mesh()

virtual Ragot::Mesh::~Mesh ( )
virtualdefault

Default virtual destructor for the Mesh class.

Cleans up the mesh and its resources.

◆ Mesh() [2/2]

Ragot::Mesh::Mesh ( mesh_info_t & mesh_info)

Construct a new Mesh object with mesh information.

Initializes the mesh with the provided mesh information.

Parameters
mesh_infoInformation about the mesh, including coordinates and rendering type.

Member Function Documentation

◆ apply_transform_to_vertices()

void Ragot::Mesh::apply_transform_to_vertices ( )
inline

Apply the current transformation to the vertices of the mesh. This method applies the transformation matrix obtained from the Transform class to each vertex in the mesh. This is useful for updating the mesh vertices after any transformation has been applied, such as translation, rotation, or scaling. It modifies the vertices in place, transforming them according to the current transformation matrix.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_faces()

virtual void Ragot::Mesh::generate_faces ( )
pure virtual

Generate faces for the mesh.

This method is pure virtual and must be implemented by derived classes. It is responsible for generating the faces of the mesh based on the vertices generated by generate_vertices.

Implemented in Ragot::ExtrudeMesh, and Ragot::RevolutionMesh.

Here is the caller graph for this function:

◆ generate_vertices()

virtual void Ragot::Mesh::generate_vertices ( )
pure virtual

Generate vertices for the mesh.

This method is pure virtual and must be implemented by derived classes. It is responsible for generating the vertices of the mesh based on the mesh information.

Implemented in Ragot::ExtrudeMesh, and Ragot::RevolutionMesh.

Here is the caller graph for this function:

◆ get_color()

uint16_t Ragot::Mesh::get_color ( ) const
inline

Get the color of the mesh.

This method returns the current color of the mesh.

Returns
uint16_t The color of the mesh.

◆ get_faces()

const std::vector< face_t > & Ragot::Mesh::get_faces ( ) const
inline

Get the faces object.

Returns
const std::vector < face_t >&
Here is the caller graph for this function:

◆ get_total_vertices() [1/2]

size_t Ragot::Mesh::get_total_vertices ( )
inline

Get the total vertices object.

Returns
size_t

◆ get_total_vertices() [2/2]

const size_t Ragot::Mesh::get_total_vertices ( ) const
inline

Get the total vertices object.

Returns
const size_t
Here is the caller graph for this function:

◆ get_vertices()

const std::vector< glm::fvec4 > & Ragot::Mesh::get_vertices ( ) const
inline

Get the vertices object.

Returns
const std::vector < glm::fvec4 >&
Here is the caller graph for this function:

◆ recalculate()

void Ragot::Mesh::recalculate ( )
inline

Recalculate the mesh vertices and faces.

Here is the call graph for this function:

◆ set_color()

void Ragot::Mesh::set_color ( uint16_t new_color)
inline

Set the color of the mesh.

This method sets the color of the mesh to the specified new color.

Parameters
new_colorThe new color to set for the mesh.

Member Data Documentation

◆ color

uint16_t Ragot::Mesh::color = 0xFFFF
protected

Color of the mesh, default is white (0xFFFF).

◆ faces

std::vector< face_t > Ragot::Mesh::faces
protected

Vector of faces representing the mesh, each face can be a triangle or a quad.

◆ mesh_info

mesh_info_t Ragot::Mesh::mesh_info
protected

Information about the mesh, including coordinates and rendering type.

◆ slices

int Ragot::Mesh::slices = 16
protected

Number of slices for generating the mesh, default is 16.

◆ vertices

std::vector< glm::fvec4 > Ragot::Mesh::vertices
protected

Vector of vertices representing the mesh in 3D space.


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