Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
TransformComponent.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include <ThirdParty/glm/glm/glm.hpp>
5 
6 namespace Engine
7 {
9  {
10  public:
11  explicit TransformComponent() noexcept;
12  explicit TransformComponent(bool isStatic) noexcept;
13  explicit TransformComponent(glm::vec3 position) noexcept;
14  explicit TransformComponent(glm::vec3 position, bool isStatic) noexcept;
15  explicit TransformComponent(glm::vec3 position, glm::vec3 rotation) noexcept;
16  explicit TransformComponent(glm::vec3 position, glm::vec3 rotation, bool isStatic) noexcept;
17  explicit TransformComponent(glm::vec3 position, glm::vec3 rotation, glm::vec3 scale) noexcept;
18  explicit TransformComponent(glm::vec3 position, glm::vec3 rotation, glm::vec3 scale, bool isStatic) noexcept;
19 
20  void SetPosition(glm::vec3 position) noexcept;
21  void SetPosition(float x, float y, float z) noexcept;
22  glm::vec3 GetPosition() noexcept;
23 
24  void SetRotation(glm::vec3 rotation) noexcept;
25  void SetRotation(float x, float y, float z) noexcept;
26  glm::vec3 GetRotation() noexcept;
27 
28  void SetScale(glm::vec3 scale) noexcept;
29  void SetScale(float x, float y, float z) noexcept;
30  glm::vec3 GetScale() noexcept;
31 
32  void SetModelMatrix(glm::mat4x4 modelMatrix) noexcept;
33  void SetModelMatrix(float modelMatrix[16]) noexcept;
34  void SetModelMatrix(glm::vec4 modelMatrix[4]) noexcept;
35  glm::mat4x4 GetModelMatrix() noexcept;
36 
37  void SetIsStatic(bool isStatic) noexcept;
38  bool GetIsStatic() noexcept;
39 
40  void Translate(glm::vec3 positionToAdd) noexcept;
41  void Translate(float x) noexcept;
42  void Translate(float x, float y) noexcept;
43  void Translate(float x, float y, float z) noexcept;
44 
45  void AddRotate(glm::vec3 rotationToAdd) noexcept;
46  void AddRotate(float x) noexcept;
47  void AddRotate(float x, float y) noexcept;
48  void AddRotate(float x, float y, float z) noexcept;
49 
50  void AddScale(glm::vec3 scaleToAdd) noexcept;
51  void AddScale(float x) noexcept;
52  void AddScale(float x, float y) noexcept;
53  void AddScale(float x, float y, float z) noexcept;
54 
55  glm::vec3 GetRight() noexcept;
56  glm::vec3 GetUp() noexcept;
57  glm::vec3 GetForward() noexcept;
58 
59  void LookAt(TransformComponent target) noexcept;
60  void LookAt(glm::vec3 targetPosition) noexcept;
61  void RotateAround(float angle, glm::vec3 axis) noexcept;
62 
63  void Update() override;
64  void UpdateModelMatrix() noexcept;
65 
66  bool operator!=(TransformComponent& other);
67  bool operator==(TransformComponent& other);
68 
69 
70  private:
71 
72  glm::vec3 position;
73  glm::vec3 rotation;
74  glm::vec3 scale;
75  bool isStatic;
76  bool shouldRecalculateModelMatrix = false;
77 
78  glm::mat4x4 modelMatrix;
79  };
80 } // namespace Engine
This is the base class for components. NOTE: only the Entity class is allowed to create this object...
Definition: Component.hpp:16
#define ENGINE_API
Definition: api.hpp:25