Brenta Engine 1.2
Loading...
Searching...
No Matches
transform.hpp
1// SPDX-License-Identifier: MIT
2// Author: Giovanni Santini
3// Mail: giovanni.santini@proton.me
4// Github: @San7o
5
6#pragma once
7
8#include <glm/glm.hpp>
9#include <glm/gtc/quaternion.hpp>
10
11namespace brenta
12{
13
15{
16public:
17
18 glm::vec3 position = glm::vec3(0);
19 glm::quat rotation = glm::identity<glm::quat>();
20 glm::vec3 scaling = glm::vec3(1.0f);
21
22 Transform() = default;
23 Transform(double x, double y, double z);
24 Transform(glm::vec3 vec);
25 Transform(Transform& other) = default;
26 Transform(const Transform& other) = default;
27
28 //
29 // Getters
30 //
31
32 // Model = Transform * Rotation * Scale
33 glm::mat4 get_model_matrix();
34 glm::vec3 get_pos() const;
35 float get_x() const;
36 float get_y() const;
37 float get_z() const;
38 glm::quat get_rotation() const;
39
40 //
41 // Setters
42 //
43
44 Transform& set_pos(glm::vec3 new_pos);
45 Transform& set_x(float x);
46 Transform& set_y(float y);
47 Transform& set_z(float z);
48 Transform& translate(const glm::vec3& translation);
49 Transform& rotate(const glm::quat &rotation);
50 Transform& rotate_x(float degrees);
51 Transform& rotate_y(float degrees);
52 Transform& rotate_z(float degrees);
53 Transform& scale(const glm::vec3& scale);
54
55
56private:
57
58 glm::mat4 model_matrix;
59 bool dirty = true; // set this to true when something was
60 // changed
61};
62
63} // namespace brenta