-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransform.cpp
More file actions
36 lines (29 loc) · 974 Bytes
/
Transform.cpp
File metadata and controls
36 lines (29 loc) · 974 Bytes
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
#include "Transform.h"
#include "Editor.h"
namespace Engine
{
glm::mat4 Transform::localSpace()const {
glm::mat4 model = glm::mat4(1.f);
model = glm::translate(model, m_position);
model = glm::rotate(model, glm::radians(m_eulerAngle.x), glm::vec3(1.0f, 0.0f, 0.0f));
model = glm::rotate(model, glm::radians(m_eulerAngle.y), glm::vec3(0.0f, 1.0f, 0.0f));
model = glm::rotate(model, glm::radians(m_eulerAngle.z), glm::vec3(0.0f, 0.0f, 1.0f));
model = glm::scale(model, m_scale * meshScaleFactor);
return model;
}
glm::mat4 Transform::globalSpace() const
{
if (parent)
return parent->globalSpace() * localSpace();
else//is root
return localSpace();
}
void Transform::drawEditorGUI_Properties()
{
ImGui::DragFloat3("Position", (float*)&m_position);
ImGui::DragFloat3("EulerAngles", (float*)&m_eulerAngle);
ImGui::DragFloat3("Scale", (float*)&m_scale);
//ImGui::SameLine();
ImGui::DragFloat("Scale Factor", &meshScaleFactor);
}
}