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
Camera.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_GRAPHICS_CAMERA_HPP_
9#define GALAXY_GRAPHICS_CAMERA_HPP_
10
11#include <glm/mat4x4.hpp>
12#include <glm/vec2.hpp>
13
14namespace galaxy
15{
19 class Camera final
20 {
21 public:
25 struct alignas(16) Data final
26 {
30 glm::mat4 m_model_view = glm::mat4 {1.0f};
31
35 glm::mat4 m_projection = glm::mat4 {1.0f};
36 };
37
41 Camera() noexcept;
42
46 Camera(Camera&&) noexcept;
47
51 Camera& operator=(Camera&&) noexcept;
52
56 Camera(const Camera&) noexcept;
57
61 Camera& operator=(const Camera&) noexcept;
62
66 ~Camera() noexcept;
67
78 void set_projection(const float left, const float right, const float bottom, const float top) noexcept;
79
86 void move(const float x, const float y) noexcept;
87
93 void move_x(const float x) noexcept;
94
100 void move_y(const float y) noexcept;
101
107 void rotate(const float degrees) noexcept;
108
114 void scale(const float scale) noexcept;
115
121 void set_scale_horizontal(const float x) noexcept;
122
128 void set_scale_vertical(const float y) noexcept;
129
135 void set_rotation(const float degrees) noexcept;
136
143 void set_positon(const float x, const float y) noexcept;
144
150 void set_positon_horizontal(const float x) noexcept;
151
157 void set_positon_vertical(const float y) noexcept;
158
167 void set_origin(const float x, const float y) noexcept;
168
172 void reset() noexcept;
173
179 [[nodiscard]]
180 const glm::vec2& get_pos() const noexcept;
181
187 [[nodiscard]]
188 float get_rotation() const noexcept;
189
195 [[nodiscard]]
196 const glm::vec2& get_scale() const noexcept;
197
203 [[nodiscard]]
204 const glm::vec2& get_origin() const noexcept;
205
211 [[nodiscard]]
212 glm::mat4& get_transform() noexcept;
213
219 [[nodiscard]]
220 const glm::mat4& get_model_view() noexcept;
221
227 [[nodiscard]]
228 const glm::mat4& get_proj() noexcept;
229
235 [[nodiscard]]
236 Data& get_data() noexcept;
237
238 private:
242 void recalculate() noexcept;
243
244 public:
249
254
259
260 private:
265
270 glm::vec2 m_pos;
271
277
282 glm::vec2 m_scale;
283
287 glm::vec2 m_origin;
288
293
297 glm::mat4 m_transform;
298 };
299} // namespace galaxy
300
301#endif
Orthographic 2D camera.
Definition Camera.hpp:20
void set_positon(const float x, const float y) noexcept
Set postion of camera.
Definition Camera.cpp:171
void move(const float x, const float y) noexcept
Move position.
Definition Camera.cpp:117
Data m_data
Camera data.
Definition Camera.hpp:264
glm::mat4 m_transform
Combined transform.
Definition Camera.hpp:297
Camera() noexcept
Constructor.
Definition Camera.cpp:20
void set_scale_vertical(const float y) noexcept
Set entity scale.
Definition Camera.cpp:159
void scale(const float scale) noexcept
Set entity scale.
Definition Camera.cpp:145
void reset() noexcept
Reset transform.
Definition Camera.cpp:199
void move_x(const float x) noexcept
Move on x axis.
Definition Camera.cpp:125
bool m_allow_rotation
Allow camera to rotate.
Definition Camera.hpp:248
float m_translation_speed
Movement speed.
Definition Camera.hpp:253
const glm::mat4 & get_model_view() noexcept
Retrieve internal transformation matrix.
Definition Camera.cpp:235
void set_positon_vertical(const float y) noexcept
Set postion of camera.
Definition Camera.cpp:185
glm::vec2 m_pos
Cached for easy retrieval. Pos.
Definition Camera.hpp:270
void set_rotation(const float degrees) noexcept
Set camera rotation.
Definition Camera.cpp:165
glm::mat4 & get_transform() noexcept
Retrieve internal transformation matrix.
Definition Camera.cpp:229
void recalculate() noexcept
Recalculates the model view matrix.
Definition Camera.cpp:252
void set_origin(const float x, const float y) noexcept
Set the origin point.
Definition Camera.cpp:191
void move_y(const float y) noexcept
Move on y axis.
Definition Camera.cpp:131
const glm::vec2 & get_scale() const noexcept
Get stored scale.
Definition Camera.cpp:219
float m_rotation
Cached for easy retrieval. Rotation.
Definition Camera.hpp:276
const glm::vec2 & get_pos() const noexcept
Get stored position.
Definition Camera.cpp:209
void rotate(const float degrees) noexcept
Rotate entity.
Definition Camera.cpp:137
bool m_dirty
Flag to see if transform needs to be recalculated.
Definition Camera.hpp:292
void set_positon_horizontal(const float x) noexcept
Set postion of camera.
Definition Camera.cpp:179
const glm::mat4 & get_proj() noexcept
Get the Camera projection.
Definition Camera.cpp:241
glm::vec2 m_scale
Cached for easy retrieval. Scale.
Definition Camera.hpp:282
float get_rotation() const noexcept
Get stored rotation.
Definition Camera.cpp:214
glm::vec2 m_origin
Transform origin point.
Definition Camera.hpp:287
Data & get_data() noexcept
Get camera view and proj.
Definition Camera.cpp:246
float m_rotation_speed
Rotational speed.
Definition Camera.hpp:258
const glm::vec2 & get_origin() const noexcept
Get origin point.
Definition Camera.cpp:224
void set_scale_horizontal(const float x) noexcept
Set entity scale.
Definition Camera.cpp:153
void set_projection(const float left, const float right, const float bottom, const float top) noexcept
Set camera projection.
Definition Camera.cpp:106
Animated.cpp galaxy.
Definition Animated.cpp:16
Camera data.
Definition Camera.hpp:26
glm::mat4 m_projection
Camera projection matrix.
Definition Camera.hpp:35
glm::mat4 m_model_view
Combined transformation matrix.
Definition Camera.hpp:30