-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransform.cpp
More file actions
73 lines (62 loc) · 1.33 KB
/
Transform.cpp
File metadata and controls
73 lines (62 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "Transform.h"
Transform::Transform()
{
m_translationMatrix = glm::mat4(1);
m_rotationMatrix = glm::mat4(1);
m_scaleMatrix = glm::mat4(1);
m_transformMatrix = glm::mat4(1);
}
Transform::~Transform()
{
}
void Transform::Translate(glm::vec3 position)
{
m_translationMatrix = glm::translate(glm::mat4(1), position);
}
void Transform::Rotate(float angle, glm::vec3 axis)
{
m_rotationMatrix = glm::rotate(m_rotationMatrix, angle, axis);
}
void Transform::Rotate(glm::vec3 euler)
{
m_rotationMatrix = glm::eulerAngleXYZ(euler.x, euler.y, euler.z);
}
void Transform::Scale(glm::vec3 scale) {
m_scaleMatrix = glm::scale(glm::mat4(1), scale);
}
glm::vec3 Transform::Rigth()
{
return glm::vec3(
m_transformMatrix[0][0],
m_transformMatrix[0][1],
m_transformMatrix[0][2]
);
}
glm::vec3 Transform::Up()
{
return glm::vec3(
m_transformMatrix[1][0],
m_transformMatrix[1][1],
m_transformMatrix[1][2]
);
}
glm::vec3 Transform::Forward()
{
return glm::vec3(
m_transformMatrix[2][0],
m_transformMatrix[2][1],
m_transformMatrix[2][2]
);
}
glm::vec3 Transform::Position()
{
return glm::vec3(
m_transformMatrix[3][0],
m_transformMatrix[3][1],
m_transformMatrix[3][2]
);
}
void Transform::UpdateMatrix()
{
m_transformMatrix = m_translationMatrix * m_rotationMatrix * m_scaleMatrix;
}