ThreeLab/Engine/Components/TransformComponent.cpp
2025-04-01 15:03:18 -05:00

19 lines
704 B
C++

#include "TransformComponent.h"
TransformComponent::TransformComponent()
: position(0.0f), rotation(0.0f), scale(1.0f) {
}
TransformComponent::~TransformComponent() {
}
glm::mat4 TransformComponent::GetMatrix() const {
glm::mat4 trans = glm::translate(glm::mat4(1.0f), position);
glm::mat4 rotX = glm::rotate(glm::mat4(1.0f), glm::radians(rotation.x), glm::vec3(1,0,0));
glm::mat4 rotY = glm::rotate(glm::mat4(1.0f), glm::radians(rotation.y), glm::vec3(0,1,0));
glm::mat4 rotZ = glm::rotate(glm::mat4(1.0f), glm::radians(rotation.z), glm::vec3(0,0,1));
glm::mat4 rot = rotZ * rotY * rotX;
glm::mat4 scl = glm::scale(glm::mat4(1.0f), scale);
return trans * rot * scl;
}