8#include <glm/gtc/matrix_transform.hpp>
9#include <nlohmann/json.hpp>
18 : m_allow_rotation {false}
19 , m_translation_speed {180.0f}
20 , m_rotation_speed {180.0f}
25 : m_allow_rotation {false}
26 , m_translation_speed {180.0f}
27 , m_rotation_speed {180.0f}
160 nlohmann::json json =
"{}"_json;
161 json[
"pos"][
"x"] =
m_pos.x;
162 json[
"pos"][
"y"] =
m_pos.y;
164 json[
"scale"][
"x"] =
m_scale.x;
165 json[
"scale"][
"y"] =
m_scale.y;
175 const auto& pos = json.at(
"pos");
176 m_pos.x = pos.at(
"x");
177 m_pos.y = pos.at(
"y");
181 const auto&
scale = json.at(
"scale");
const glm::mat4 & get_proj()
Get the Camera projection.
void set_viewport(const float width, const float height)
Set Viewport.
const glm::vec2 & get_viewport() const
Get camera viewport.
float m_translation_speed
Movement speed.
void set_projection(const float left, const float right, const float bottom, const float top)
Set camera projection.
nlohmann::json serialize() override
Serializes object.
void translate(const float x, const float y) override
Translate (move) position.
Camera & operator=(Camera &&)
Move assignment operator.
void deserialize(const nlohmann::json &json) override
Deserializes from object.
glm::vec2 m_viewport
Camera viewport size.
virtual ~Camera()
Destructor.
void recalculate()
Recalculates the model view matrix.
Data & get_data()
Get camera view and proj.
void rotate(const float degrees) override
Rotate entity.
bool m_allow_rotation
Allow camera to rotate.
const glm::mat4 & get_model_view()
Retrieve internal transformation matrix.
float m_rotation_speed
Rotational speed.
glm::mat4 m_model_view
Combined transformation matrix.
glm::mat4 m_projection
Camera projection matrix.