Raftel Engine
 
Loading...
Searching...
No Matches
Raftel::Transform2D Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Transform2D()

Raftel::Transform2D::Transform2D ( )

Default constructor for Transform2D.

Initializes the transformation with default values:

  • position: (0,0)
  • scale: (1.0, 1.0)
  • angle: 0.0f
  • velocity: (0.0f, 0.0f)

◆ ~Transform2D()

Raftel::Transform2D::~Transform2D ( )

Destructor for Transform2D.

Cleans up any resources used by the transformation (though none are dynamically allocated here).

Member Function Documentation

◆ ApplyTransform()

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.

◆ EndTransform()

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.

◆ Rotate()

void Raftel::Transform2D::Rotate ( float angle)

Rotates the object by the specified angle.

This method updates the object's rotation angle.

Parameters
angleThe angle (in degrees) to rotate the object by.

◆ Scale()

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.

Parameters
scaleThe scaling factor to apply to the object.
deltaTimeThe time elapsed, used to scale the transformation.

◆ Translate()

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.

Parameters
deltaTimeThe time elapsed, used to scale the velocity.

Member Data Documentation

◆ angle_

float Raftel::Transform2D::angle_

The angle of rotation of the object.

Definition at line 77 of file transform.hpp.

◆ position_

Vec2 Raftel::Transform2D::position_

The position of the object in 2D space.

Definition at line 74 of file transform.hpp.

◆ scale_

Vec2 Raftel::Transform2D::scale_

The scale factor applied to the object in 2D space.

Definition at line 75 of file transform.hpp.

◆ velocity_

Vec2 Raftel::Transform2D::velocity_

The velocity of the object for translation.

Definition at line 76 of file transform.hpp.


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