10#include <glm/gtc/matrix_transform.hpp>
11#include <glm/gtc/type_ptr.hpp>
21 : m_allow_rotation {
false}
22 , m_translation_speed {1.0f}
23 , m_rotation_speed {1.0f}
26 , m_scale {1.0f, 1.0f}
27 , m_origin {0.0f, 0.0f}
34 this->m_allow_rotation = c.m_allow_rotation;
35 this->m_translation_speed = c.m_translation_speed;
36 this->m_rotation_speed = c.m_rotation_speed;
37 this->m_data.m_model_view = std::move(c.m_data.m_model_view);
38 this->m_data.m_projection = std::move(c.m_data.m_projection);
39 this->m_pos = std::move(c.m_pos);
40 this->m_rotation = c.m_rotation;
41 this->m_scale = std::move(c.m_scale);
42 this->m_origin = std::move(c.m_origin);
43 this->m_dirty = c.m_dirty;
44 this->m_transform = std::move(c.m_transform);
51 this->m_allow_rotation = c.m_allow_rotation;
52 this->m_translation_speed = c.m_translation_speed;
53 this->m_rotation_speed = c.m_rotation_speed;
54 this->m_data.m_model_view = std::move(c.m_data.m_model_view);
55 this->m_data.m_projection = std::move(c.m_data.m_projection);
56 this->m_pos = std::move(c.m_pos);
57 this->m_rotation = c.m_rotation;
58 this->m_scale = std::move(c.m_scale);
59 this->m_origin = std::move(c.m_origin);
60 this->m_dirty = c.m_dirty;
61 this->m_transform = std::move(c.m_transform);
69 this->m_allow_rotation = c.m_allow_rotation;
70 this->m_translation_speed = c.m_translation_speed;
71 this->m_rotation_speed = c.m_rotation_speed;
72 this->m_data.m_model_view = c.m_data.m_model_view;
73 this->m_data.m_projection = c.m_data.m_projection;
74 this->m_pos = c.m_pos;
75 this->m_rotation = c.m_rotation;
76 this->m_scale = c.m_scale;
77 this->m_origin = c.m_origin;
78 this->m_dirty = c.m_dirty;
79 this->m_transform = c.m_transform;
86 this->m_allow_rotation = c.m_allow_rotation;
87 this->m_translation_speed = c.m_translation_speed;
88 this->m_rotation_speed = c.m_rotation_speed;
89 this->m_data.m_model_view = c.m_data.m_model_view;
90 this->m_data.m_projection = c.m_data.m_projection;
91 this->m_pos = c.m_pos;
92 this->m_rotation = c.m_rotation;
93 this->m_scale = c.m_scale;
94 this->m_origin = c.m_origin;
95 this->m_dirty = c.m_dirty;
96 this->m_transform = c.m_transform;
109 m_origin.x = right * 0.5f;
110 m_origin.y = bottom * 0.5f;
112 m_data.m_projection = glm::ortho(left, right, bottom, top, -1.0f, 1.0f);
119 m_pos.x += (x * m_translation_speed);
120 m_pos.y += (y * m_translation_speed);
127 m_pos.x += (x * m_translation_speed);
133 m_pos.y += (y * m_translation_speed);
139 m_rotation += (degrees * m_rotation_speed);
140 m_rotation = std::clamp(m_rotation, 0.0f, 360.0f);
167 m_rotation = std::clamp(degrees, 0.0f, 360.0f);
201 m_pos = {0.0f, 0.0f};
256 const auto origin = glm::vec3 {
m_origin, 0.0f};
260 rotation = glm::translate(rotation, -origin);
const constexpr auto identity_matrix
Camera.cpp galaxy.
const constexpr auto rotation_vec
void set_positon(const float x, const float y) noexcept
Set postion of camera.
void move(const float x, const float y) noexcept
Move position.
Camera & operator=(Camera &&) noexcept
Move assignment operator.
glm::mat4 m_transform
Combined transform.
Camera() noexcept
Constructor.
void set_scale_vertical(const float y) noexcept
Set entity scale.
void scale(const float scale) noexcept
Set entity scale.
void reset() noexcept
Reset transform.
void move_x(const float x) noexcept
Move on x axis.
const glm::mat4 & get_model_view() noexcept
Retrieve internal transformation matrix.
void set_positon_vertical(const float y) noexcept
Set postion of camera.
glm::vec2 m_pos
Cached for easy retrieval. Pos.
void set_rotation(const float degrees) noexcept
Set camera rotation.
glm::mat4 & get_transform() noexcept
Retrieve internal transformation matrix.
void recalculate() noexcept
Recalculates the model view matrix.
void set_origin(const float x, const float y) noexcept
Set the origin point.
void move_y(const float y) noexcept
Move on y axis.
const glm::vec2 & get_scale() const noexcept
Get stored scale.
float m_rotation
Cached for easy retrieval. Rotation.
const glm::vec2 & get_pos() const noexcept
Get stored position.
void rotate(const float degrees) noexcept
Rotate entity.
bool m_dirty
Flag to see if transform needs to be recalculated.
void set_positon_horizontal(const float x) noexcept
Set postion of camera.
const glm::mat4 & get_proj() noexcept
Get the Camera projection.
glm::vec2 m_scale
Cached for easy retrieval. Scale.
float get_rotation() const noexcept
Get stored rotation.
glm::vec2 m_origin
Transform origin point.
Data & get_data() noexcept
Get camera view and proj.
const glm::vec2 & get_origin() const noexcept
Get origin point.
~Camera() noexcept
Destructor.
void set_scale_horizontal(const float x) noexcept
Set entity scale.
void set_projection(const float left, const float right, const float bottom, const float top) noexcept
Set camera projection.
glm::mat4 m_projection
Camera projection matrix.
glm::mat4 m_model_view
Combined transformation matrix.