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
Transform.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_GRAPHICS_TRANSFORM_HPP_
9#define GALAXY_GRAPHICS_TRANSFORM_HPP_
10
11#include <glm/mat4x4.hpp>
12
13namespace galaxy
14{
15 namespace graphics
16 {
21 {
22 public:
26 Transform();
27
32
37
41 Transform(const Transform&);
42
47
51 virtual ~Transform();
52
59 virtual void translate(const float x, const float y);
60
66 virtual void rotate(const float degrees);
67
73 void scale(const float scale);
74
80 void set_scale_horizontal(const float x);
81
87 void set_scale_vertical(const float y);
88
95 void set_pos(const float x, const float y);
96
102 void set_rotation(const float degrees);
103
112 void set_origin(const float x, const float y);
113
117 void reset();
118
124 [[nodiscard]]
125 const glm::vec2& get_pos() const;
126
132 [[nodiscard]]
133 float get_rotation() const;
134
140 [[nodiscard]]
141 const glm::vec2& get_scale() const;
142
148 [[nodiscard]]
149 const glm::vec2& get_origin() const;
150
156 [[nodiscard]]
157 glm::mat4& get_transform();
158
159 protected:
164 glm::vec2 m_pos;
165
171
176 glm::vec2 m_scale;
177
181 glm::vec2 m_origin;
182
187
191 glm::mat4 m_transform;
192 };
193 } // namespace graphics
194} // namespace galaxy
195
196#endif
Defines the 2D transformation of an entity.
Definition Transform.hpp:21
const glm::vec2 & get_origin() const
Get origin point.
void set_scale_vertical(const float y)
Set entity scale.
virtual void rotate(const float degrees)
Rotate entity.
Definition Transform.cpp:94
glm::vec2 m_origin
Transform origin point.
void set_pos(const float x, const float y)
Sets position without moving the entity.
void set_origin(const float x, const float y)
Set the origin point.
Transform & operator=(Transform &&)
Move assignment operator.
Definition Transform.cpp:42
const glm::vec2 & get_pos() const
Get stored position.
virtual void translate(const float x, const float y)
Translate (move) position.
Definition Transform.cpp:86
bool m_dirty
Flag to see if transform needs to be recalculated.
const glm::vec2 & get_scale() const
Get stored scale.
float get_rotation() const
Get stored rotation.
void set_rotation(const float degrees)
Set the entity rotation.
float m_rotation
Cached for easy retrieval. Rotation.
virtual ~Transform()
Destructor.
Definition Transform.cpp:82
void reset()
Reset transform.
glm::vec2 m_scale
Cached for easy retrieval. Scale.
void set_scale_horizontal(const float x)
Set entity scale.
void scale(const float scale)
Set entity scale.
glm::mat4 & get_transform()
Retrieve internal transformation matrix.
glm::vec2 m_pos
Cached for easy retrieval. Pos.
glm::mat4 m_transform
Combined transform.
Animated.cpp galaxy.
Definition Animated.cpp:16