galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::graphics::Transform Class Reference

Defines the 2D transformation of an entity. More...

#include <Transform.hpp>

+ Inheritance diagram for galaxy::graphics::Transform:
+ Collaboration diagram for galaxy::graphics::Transform:

Public Member Functions

 Transform ()
 Constructor.
 
 Transform (Transform &&)
 Move constructor.
 
Transformoperator= (Transform &&)
 Move assignment operator.
 
 Transform (const Transform &)
 Copy constructor.
 
Transformoperator= (const Transform &)
 Copy assignment operator.
 
virtual ~Transform ()
 Destructor.
 
virtual void translate (const float x, const float y)
 Translate (move) position.
 
virtual void rotate (const float degrees)
 Rotate entity.
 
void scale (const float scale)
 Set entity scale.
 
void set_scale_horizontal (const float x)
 Set entity scale.
 
void set_scale_vertical (const float y)
 Set entity scale.
 
void set_pos (const float x, const float y)
 Sets position without moving the entity.
 
void set_rotation (const float degrees)
 Set the entity rotation.
 
void set_origin (const float x, const float y)
 Set the origin point.
 
void reset ()
 Reset transform.
 
const glm::vec2 & get_pos () const
 Get stored position.
 
float get_rotation () const
 Get stored rotation.
 
const glm::vec2 & get_scale () const
 Get stored scale.
 
const glm::vec2 & get_origin () const
 Get origin point.
 
glm::mat4 & get_transform ()
 Retrieve internal transformation matrix.
 

Protected Attributes

glm::vec2 m_pos
 Cached for easy retrieval. Pos.
 
float m_rotation
 Cached for easy retrieval. Rotation.
 
glm::vec2 m_scale
 Cached for easy retrieval. Scale.
 
glm::vec2 m_origin
 Transform origin point.
 
bool m_dirty
 Flag to see if transform needs to be recalculated.
 
glm::mat4 m_transform
 Combined transform.
 

Detailed Description

Defines the 2D transformation of an entity.

Definition at line 20 of file Transform.hpp.

Constructor & Destructor Documentation

◆ Transform() [1/3]

galaxy::graphics::Transform::Transform ( )

Constructor.

Definition at line 22 of file Transform.cpp.

◆ Transform() [2/3]

galaxy::graphics::Transform::Transform ( Transform && t)

Move constructor.

Definition at line 32 of file Transform.cpp.

◆ Transform() [3/3]

galaxy::graphics::Transform::Transform ( const Transform & t)

Copy constructor.

Definition at line 57 of file Transform.cpp.

◆ ~Transform()

galaxy::graphics::Transform::~Transform ( )
virtual

Destructor.

Definition at line 82 of file Transform.cpp.

Member Function Documentation

◆ operator=() [1/2]

Transform & galaxy::graphics::Transform::operator= ( Transform && t)

Move assignment operator.

Definition at line 42 of file Transform.cpp.

+ Here is the caller graph for this function:

◆ operator=() [2/2]

Transform & galaxy::graphics::Transform::operator= ( const Transform & t)

Copy assignment operator.

Definition at line 67 of file Transform.cpp.

◆ translate()

void galaxy::graphics::Transform::translate ( const float x,
const float y )
virtual

Translate (move) position.

Parameters
xHow far to translate on x axis.
yHow far to translate on y axis.

Reimplemented in galaxy::graphics::Camera.

Definition at line 86 of file Transform.cpp.

+ Here is the caller graph for this function:

◆ rotate()

void galaxy::graphics::Transform::rotate ( const float degrees)
virtual

Rotate entity.

Parameters
degreesAdditive. Min -360, max 360.

Reimplemented in galaxy::graphics::Camera.

Definition at line 94 of file Transform.cpp.

+ Here is the caller graph for this function:

◆ scale()

void galaxy::graphics::Transform::scale ( const float scale)

Set entity scale.

Parameters
scaleValue to scale by.

Definition at line 102 of file Transform.cpp.

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

◆ set_scale_horizontal()

void galaxy::graphics::Transform::set_scale_horizontal ( const float x)

Set entity scale.

Parameters
xValue to scale horizontal axis by.

Definition at line 110 of file Transform.cpp.

+ Here is the caller graph for this function:

◆ set_scale_vertical()

void galaxy::graphics::Transform::set_scale_vertical ( const float y)

Set entity scale.

Parameters
yValue to scale vertical axis by.

Definition at line 116 of file Transform.cpp.

+ Here is the caller graph for this function:

◆ set_pos()

void galaxy::graphics::Transform::set_pos ( const float x,
const float y )

Sets position without moving the entity.

Parameters
xX position to set.
yY position to set.

Definition at line 122 of file Transform.cpp.

+ Here is the caller graph for this function:

◆ set_rotation()

void galaxy::graphics::Transform::set_rotation ( const float degrees)

Set the entity rotation.

Parameters
degreesMin -360, max 360.

Definition at line 130 of file Transform.cpp.

+ Here is the caller graph for this function:

◆ set_origin()

void galaxy::graphics::Transform::set_origin ( const float x,
const float y )

Set the origin point.

Only affects rotation and scale.

Parameters
xX position to set origin to.
yY position to set origin to.

Definition at line 136 of file Transform.cpp.

+ Here is the caller graph for this function:

◆ reset()

void galaxy::graphics::Transform::reset ( )

Reset transform.

Definition at line 144 of file Transform.cpp.

+ Here is the caller graph for this function:

◆ get_pos()

const glm::vec2 & galaxy::graphics::Transform::get_pos ( ) const
nodiscard

Get stored position.

Returns
Const glm::vec2 reference.

Definition at line 153 of file Transform.cpp.

+ Here is the caller graph for this function:

◆ get_rotation()

float galaxy::graphics::Transform::get_rotation ( ) const
nodiscard

Get stored rotation.

Returns
Float.

Definition at line 158 of file Transform.cpp.

+ Here is the caller graph for this function:

◆ get_scale()

const glm::vec2 & galaxy::graphics::Transform::get_scale ( ) const
nodiscard

Get stored scale.

Returns
Const glm::vec2 reference.

Definition at line 163 of file Transform.cpp.

+ Here is the caller graph for this function:

◆ get_origin()

const glm::vec2 & galaxy::graphics::Transform::get_origin ( ) const
nodiscard

Get origin point.

Returns
Const glm::vec2 reference.

Definition at line 168 of file Transform.cpp.

+ Here is the caller graph for this function:

◆ get_transform()

glm::mat4 & galaxy::graphics::Transform::get_transform ( )
nodiscard

Retrieve internal transformation matrix.

Returns
glm::mat4 reference.

Definition at line 173 of file Transform.cpp.

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

Member Data Documentation

◆ m_pos

glm::vec2 galaxy::graphics::Transform::m_pos
protected

Cached for easy retrieval. Pos.

Definition at line 164 of file Transform.hpp.

◆ m_rotation

float galaxy::graphics::Transform::m_rotation
protected

Cached for easy retrieval. Rotation.

Definition at line 170 of file Transform.hpp.

◆ m_scale

glm::vec2 galaxy::graphics::Transform::m_scale
protected

Cached for easy retrieval. Scale.

Definition at line 176 of file Transform.hpp.

◆ m_origin

glm::vec2 galaxy::graphics::Transform::m_origin
protected

Transform origin point.

Definition at line 181 of file Transform.hpp.

◆ m_dirty

bool galaxy::graphics::Transform::m_dirty
protected

Flag to see if transform needs to be recalculated.

Definition at line 186 of file Transform.hpp.

◆ m_transform

glm::mat4 galaxy::graphics::Transform::m_transform
protected

Combined transform.

Definition at line 191 of file Transform.hpp.


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