3D Graphics Engine for ESP32
 
Loading...
Searching...
No Matches
Ragot::Transform Class Reference

A class representing a 3D transformation with position, rotation, and scale. More...

#include <Transform.hpp>

Inheritance diagram for Ragot::Transform:
Inheritance graph
Collaboration diagram for Ragot::Transform:
Collaboration graph

Public Member Functions

 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).
 
virtual mat4 get_transform_matrix ()
 Gets the transformation matrix that combines position, rotation, and scale.
 

Protected Attributes

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.
 

Private Attributes

mat4 transform_matrix
 The transformation matrix that combines position, rotation, and scale.
 

Detailed Description

A class representing a 3D transformation with position, rotation, and scale.

This class provides methods to set and get the position, rotation, and scale of a 3D object. It also provides a method to get the transformation matrix that combines these transformations.

Constructor & Destructor Documentation

◆ Transform()

Ragot::Transform::Transform ( )
inline

Default constructor for the Transform class.

Initializes position to (0, 0, 0), rotation to (0, 0, 0), and scale to (1, 1, 1).

◆ ~Transform()

virtual Ragot::Transform::~Transform ( )
virtualdefault

Virtual destructor for the Transform class.

Ensures proper cleanup of derived classes.

Member Function Documentation

◆ get_position()

vec3 Ragot::Transform::get_position ( ) const
inline

Gets the current position of the object.

Returns
vec3 The current position.
Here is the caller graph for this function:

◆ get_rotation()

vec3 Ragot::Transform::get_rotation ( ) const
inline

Gets the current rotation of the object.

Returns
vec3 The current rotation in degrees around each axis (x, y, z).
Here is the caller graph for this function:

◆ get_scale()

vec3 Ragot::Transform::get_scale ( ) const
inline

Sets the scale of the object uniformly.

Parameters
scaleThe new uniform scale factor.
Here is the caller graph for this function:

◆ get_transform_matrix()

virtual mat4 Ragot::Transform::get_transform_matrix ( )
inlinevirtual

Gets the transformation matrix that combines position, rotation, and scale.

This method recalculates the transformation matrix if it is dirty.

Returns
mat4 The transformation matrix.

Reimplemented in Ragot::Node.

Here is the caller graph for this function:

◆ is_dirty()

bool Ragot::Transform::is_dirty ( ) const
inline

Checks if the transformation matrix is dirty (needs recalculation).

Returns
true if the transformation matrix is dirty, false otherwise.

◆ rotate()

void Ragot::Transform::rotate ( const float angle,
const vec3 & axis )
inline

Rotates the object by a specified angle around a given axis.

Parameters
angleThe angle in degrees to rotate.
axisThe axis around which to rotate, as a vec3.

◆ set_position()

void Ragot::Transform::set_position ( const vec3 & pos)
inline

Sets the position of the object.

Parameters
posThe new position as a vec3.
Here is the caller graph for this function:

◆ set_rotation()

void Ragot::Transform::set_rotation ( const vec3 & rot)
inline

Moves the object by a specified vector.

Parameters
offsetThe vector by which to move the object.

◆ set_scale()

void Ragot::Transform::set_scale ( const vec3 & scale)
inline

Sets the scale of the object.

Parameters
scaleThe new scale as a vec3.

Member Data Documentation

◆ dirty

bool Ragot::Transform::dirty = true
protected

Flag indicating whether the transformation matrix needs to be recalculated.

◆ position

vec3 Ragot::Transform::position
protected

The position of the object in 3D space.

◆ rotation

vec3 Ragot::Transform::rotation
protected

The rotation of the object in degrees around each axis (x, y, z).

◆ scale

vec3 Ragot::Transform::scale
protected

The scale of the object in 3D space, default is (1, 1, 1).

◆ transform_matrix

mat4 Ragot::Transform::transform_matrix
private

The transformation matrix that combines position, rotation, and scale.


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