blob: b7230f711e4f8d6de933917c4e32ba2d86731539 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#include "transform.h"
#include <glm/gtx/transform.hpp>
Transform::Transform(glm::vec3 pos, glm::vec3 rot, glm::vec3 scale) : pos {pos}, rot {rot}, scale {scale} { }
glm::mat4
Transform::GetModel() const
{
const auto posMat = glm::translate(pos);
const auto scaleMat = glm::scale(scale);
const auto rotX = glm::rotate(rot.x, glm::vec3(1.0, 0.0, 0.0));
const auto rotY = glm::rotate(rot.y, glm::vec3(0.0, 1.0, 0.0));
const auto rotZ = glm::rotate(rot.z, glm::vec3(0.0, 0.0, 1.0));
const auto rotMat = rotY * rotX * rotZ;
return posMat * rotMat * scaleMat;
}
|