Elevate Engine 1
Loading...
Searching...
No Matches
Elevate::Transform Class Reference

#include <Transform.h>

Public Member Functions

 Transform ()
 
void SetPosition (glm::vec3 pos)
 
void SetRotation (glm::vec3 rot)
 
void SetScale (glm::vec3 scale)
 
glm::vec3 & GetPosition ()
 
const glm::vec3 & GetPosition () const
 
glm::vec3 & GetRotation ()
 
const glm::vec3 & GetRotation () const
 
glm::vec3 & GetScale ()
 
const glm::vec3 & GetScale () const
 
glm::vec3 GetRight () const
 
glm::vec3 GetUp () const
 
glm::vec3 GetBackward () const
 
glm::vec3 GetForward () const
 
glm::vec3 GetGlobalScale () const
 
const glm::mat4 & GetModelMatrix () const
 
void UpdateModelMatrix ()
 
ComponentLayout GetLayout () const
 

Detailed Description

Definition at line 13 of file Transform.h.

Constructor & Destructor Documentation

◆ Transform()

Elevate::Transform::Transform ( )

Definition at line 7 of file Transform.cpp.

8{
9 m_ModelMatrix = glm::mat4(0.0f);
10 position = glm::vec3(0.0f);
11 rotation = glm::vec3(0.0f);
12 scale = glm::vec3(1.0f);
13 m_isDirty = true;
14}

Member Function Documentation

◆ GetBackward()

glm::vec3 Elevate::Transform::GetBackward ( ) const

Definition at line 26 of file Transform.cpp.

27{
28 return glm::normalize(glm::vec3(GetModelMatrix()[2]));
29}
const glm::mat4 & GetModelMatrix() const
Definition Transform.cpp:41

◆ GetForward()

glm::vec3 Elevate::Transform::GetForward ( ) const

Definition at line 31 of file Transform.cpp.

32{
33 return -glm::normalize(glm::vec3(GetModelMatrix()[2]));
34}

◆ GetGlobalScale()

glm::vec3 Elevate::Transform::GetGlobalScale ( ) const

Definition at line 36 of file Transform.cpp.

37{
38 return { glm::length(GetRight()), glm::length(GetUp()), glm::length(GetBackward()) };
39}
glm::vec3 GetBackward() const
Definition Transform.cpp:26
glm::vec3 GetUp() const
Definition Transform.cpp:21
glm::vec3 GetRight() const
Definition Transform.cpp:16

◆ GetLayout()

ComponentLayout Elevate::Transform::GetLayout ( ) const
inline

Definition at line 41 of file Transform.h.

42 {
43 return ComponentLayout(
44 "Transform",
45 {
46 {"Positon", ComponentDataType::Float3, &position},
47 {"Rotation", ComponentDataType::Float3, &rotation},
48 {"Scale", ComponentDataType::Float3, &scale}
49 }
50 );
51 }

◆ GetModelMatrix()

const glm::mat4 & Elevate::Transform::GetModelMatrix ( ) const

Definition at line 41 of file Transform.cpp.

42{
43 if (m_isDirty)
44 {
45 const_cast<Transform*>(this)->UpdateModelMatrix();
46 }
47 return m_ModelMatrix;
48}

◆ GetPosition() [1/2]

glm::vec3 & Elevate::Transform::GetPosition ( )
inline

Definition at line 23 of file Transform.h.

23{ return position; }

◆ GetPosition() [2/2]

const glm::vec3 & Elevate::Transform::GetPosition ( ) const
inline

Definition at line 24 of file Transform.h.

24{ return position; }

◆ GetRight()

glm::vec3 Elevate::Transform::GetRight ( ) const

Definition at line 16 of file Transform.cpp.

17{
18 return glm::normalize(glm::vec3(GetModelMatrix()[0]));
19}

◆ GetRotation() [1/2]

glm::vec3 & Elevate::Transform::GetRotation ( )
inline

Definition at line 25 of file Transform.h.

25{ return rotation; }

◆ GetRotation() [2/2]

const glm::vec3 & Elevate::Transform::GetRotation ( ) const
inline

Definition at line 26 of file Transform.h.

26{ return rotation; }

◆ GetScale() [1/2]

glm::vec3 & Elevate::Transform::GetScale ( )
inline

Definition at line 27 of file Transform.h.

27{ return scale; }

◆ GetScale() [2/2]

const glm::vec3 & Elevate::Transform::GetScale ( ) const
inline

Definition at line 28 of file Transform.h.

28{ return scale; }

◆ GetUp()

glm::vec3 Elevate::Transform::GetUp ( ) const

Definition at line 21 of file Transform.cpp.

22{
23 return glm::normalize(glm::vec3(GetModelMatrix()[1]));
24}

◆ SetPosition()

void Elevate::Transform::SetPosition ( glm::vec3  pos)
inline

Definition at line 19 of file Transform.h.

19{ this->position = pos; m_isDirty = true; }

◆ SetRotation()

void Elevate::Transform::SetRotation ( glm::vec3  rot)
inline

Definition at line 20 of file Transform.h.

20{ this->rotation = rot; m_isDirty = true; }

◆ SetScale()

void Elevate::Transform::SetScale ( glm::vec3  scale)
inline

Definition at line 21 of file Transform.h.

21{ this->scale = scale; m_isDirty = true; }

◆ UpdateModelMatrix()

void Elevate::Transform::UpdateModelMatrix ( )

Definition at line 50 of file Transform.cpp.

51{
52 glm::mat4 model = glm::mat4(1.0f);
53 model = glm::translate(model, position);
54
55 model = glm::rotate(model, glm::radians(rotation.y), { 0, 1, 0 });
56 model = glm::rotate(model, glm::radians(rotation.x), { 1, 0, 0 });
57 model = glm::rotate(model, glm::radians(rotation.z), { 0, 0, 1 });
58
59 model = glm::scale(model, scale);
60 m_ModelMatrix = model;
61 m_isDirty = false;
62}

The documentation for this class was generated from the following files: