Represents a 2D transformation for an object (translation, rotation, and scaling). More...
#include <transform.hpp>
Public Member Functions | |
Transform2D () | |
Default constructor for Transform2D . | |
void | Translate (float deltaTime) |
Translates the object by applying its velocity over time. | |
void | Rotate (float angle) |
Rotates the object by the specified angle. | |
void | Scale (Vec2 scale, float deltaTime) |
Scales the object by the given factor. | |
void | ApplyTransform () |
Applies the accumulated transformations (translation, rotation, scaling). | |
void | EndTransform () |
Ends the current transformation and restores the previous matrix state. | |
~Transform2D () | |
Destructor for Transform2D . | |
Public Attributes | |
Vec2 | position_ |
The position of the object in 2D space. | |
Vec2 | scale_ |
The scale factor applied to the object in 2D space. | |
Vec2 | velocity_ |
The velocity of the object for translation. | |
float | angle_ |
The angle of rotation of the object. | |
Represents a 2D transformation for an object (translation, rotation, and scaling).
The Transform2D
class allows you to apply various 2D transformations to an object, including movement (via translation), rotation, and scaling. The transformations are stored in the class's member variables and can be applied to render the object with the desired transformations.
Definition at line 60 of file transform.hpp.
Raftel::Transform2D::Transform2D | ( | ) |
Default constructor for Transform2D
.
Initializes the transformation with default values:
Raftel::Transform2D::~Transform2D | ( | ) |
Destructor for Transform2D
.
Cleans up any resources used by the transformation (though none are dynamically allocated here).
void Raftel::Transform2D::ApplyTransform | ( | ) |
Applies the accumulated transformations (translation, rotation, scaling).
This method applies the current transformation (position, scale, and rotation) to the object. The transformation is applied by modifying the OpenGL matrix stack.
void Raftel::Transform2D::EndTransform | ( | ) |
Ends the current transformation and restores the previous matrix state.
This method pops the current transformation from the OpenGL matrix stack, restoring the previous transformation state.
void Raftel::Transform2D::Rotate | ( | float | angle | ) |
Rotates the object by the specified angle.
This method updates the object's rotation angle.
angle | The angle (in degrees) to rotate the object by. |
void Raftel::Transform2D::Scale | ( | Vec2 | scale, |
float | deltaTime ) |
Scales the object by the given factor.
This method updates the scale of the object by a scaling factor.
scale | The scaling factor to apply to the object. |
deltaTime | The time elapsed, used to scale the transformation. |
void Raftel::Transform2D::Translate | ( | float | deltaTime | ) |
Translates the object by applying its velocity over time.
This method updates the object's position based on its velocity, scaled by the deltaTime
.
deltaTime | The time elapsed, used to scale the velocity. |
float Raftel::Transform2D::angle_ |
The angle of rotation of the object.
Definition at line 77 of file transform.hpp.
Vec2 Raftel::Transform2D::position_ |
The position of the object in 2D space.
Definition at line 74 of file transform.hpp.
Vec2 Raftel::Transform2D::scale_ |
The scale factor applied to the object in 2D space.
Definition at line 75 of file transform.hpp.
Vec2 Raftel::Transform2D::velocity_ |
The velocity of the object for translation.
Definition at line 76 of file transform.hpp.