| Fling Engine 0.00.1 Fling Engine is a game engine written in Vulkan

Transform.h
Go to the documentation of this file.
1 #pragma once
2
3 #include "Serilization.h"
4 #include "FlingMath.h"
5
6 namespace Fling
7 {
8 struct Transform
9 {
10 glm::mat4 GetWorldMatrix() const;
11
12 static void CalculateWorldMatrix(Transform& t_Trans);
13
14 bool operator==(const Transform &other) const;
15 bool operator!=(const Transform &other) const;
16 friend std::ostream& operator << (std::ostream& t_OutStream, const Fling::Transform& t_Transform);
17
18 template<class Archive>
19 void serialize(Archive & t_Archive);
20
21 inline const glm::vec3& GetPos() const { return m_Pos; }
22 inline const glm::vec3& GetScale() const { return m_Scale; }
23 inline const glm::vec3& GetRotation() const { return m_Rotation; }
24 inline const glm::mat4& GetWorldMat() const { return m_worldMat; }
25
26 void SetPos(const glm::vec3& t_Pos);
27 void SetScale(const glm::vec3& t_Scale);
28 void SetRotation(const glm::vec3& t_Rot);
29
30 //private:
31 glm::vec3 m_Pos { 0.0f, 0.0f, 0.0f };
32 glm::vec3 m_Rotation { 0.0f, 0.0f, 0.0f };
33 glm::vec3 m_Scale { 1.0f, 1.0f, 1.0f };
34 glm::mat4 m_worldMat {};
35 };
36
38 template<class Archive>
39 void Transform::serialize(Archive & t_Archive)
40 {
41 t_Archive(
42 cereal::make_nvp("POS_X", m_Pos.x),
43 cereal::make_nvp("POS_Y", m_Pos.y),
44 cereal::make_nvp("POS_Z", m_Pos.z),
45
46 cereal::make_nvp("SCALE_X", m_Scale.x),
47 cereal::make_nvp("SCALE_Y", m_Scale.y),
48 cereal::make_nvp("SCALE_Z", m_Scale.z),
49
50 cereal::make_nvp("ROT_X", m_Rotation.x),
51 cereal::make_nvp("ROT_Y", m_Rotation.y),
52 cereal::make_nvp("ROT_Z", m_Rotation.z)
53 );
54 }
55 } // namespace Fling
Fling::Transform::GetPos
const glm::vec3 & GetPos() const
Definition: Transform.h:21
Fling::Transform::GetWorldMat
const glm::mat4 & GetWorldMat() const
Definition: Transform.h:24
Fling::Transform::CalculateWorldMatrix
static void CalculateWorldMatrix(Transform &t_Trans)
Definition: Transform.cpp:37
FlingMath.h
Fling::Transform::m_worldMat
glm::mat4 m_worldMat
Definition: Transform.h:34
Fling::Transform::operator==
bool operator==(const Transform &other) const
Definition: Transform.cpp:7
Fling::Transform::m_Rotation
glm::vec3 m_Rotation
Definition: Transform.h:32
Fling::Transform::operator!=
bool operator!=(const Transform &other) const
Definition: Transform.cpp:12
Fling::Transform::GetRotation
const glm::vec3 & GetRotation() const
Definition: Transform.h:23
Fling::Transform::m_Pos
glm::vec3 m_Pos
Definition: Transform.h:31
Fling::Transform::SetScale
void SetScale(const glm::vec3 &t_Scale)
Definition: Transform.cpp:53
Serilization.h
Fling::Transform::operator<<
friend std::ostream & operator<<(std::ostream &t_OutStream, const Fling::Transform &t_Transform)
Definition: Transform.cpp:17
Fling::Transform::GetWorldMatrix
glm::mat4 GetWorldMatrix() const
Definition: Transform.cpp:26
Fling::Transform::serialize
void serialize(Archive &t_Archive)
Serilazation to an archive.
Definition: Transform.h:39
Fling::Transform
Definition: Transform.h:8
Fling::Transform::m_Scale
glm::vec3 m_Scale
Definition: Transform.h:33
Fling::Transform::GetScale
const glm::vec3 & GetScale() const
Definition: Transform.h:22
Fling::Transform::SetRotation
void SetRotation(const glm::vec3 &t_Rot)
Definition: Transform.cpp:58
Fling::Transform::SetPos
void SetPos(const glm::vec3 &t_Pos)
Definition: Transform.cpp:48
Fling
Definition: Engine.h:29