6#include <brenta/transform.hpp>
10Transform::Transform(
double x,
double y,
double z)
12 this->position = glm::vec3(x, y, z);
17Transform::Transform(glm::vec3 vec)
24glm::mat4 Transform::get_model_matrix()
28 glm::mat4 T = glm::translate(glm::mat4(1.0f), this->position);
29 glm::mat4 R = glm::mat4_cast(this->rotation);
30 glm::mat4 S = glm::scale(glm::mat4(1.0f), this->scaling);
32 this->model_matrix = T * R * S;
36 return this->model_matrix;
39glm::vec3 Transform::get_pos()
const
41 return this->position;
44float Transform::get_x()
const
46 return this->position.x;
49float Transform::get_y()
const
51 return this->position.y;
54float Transform::get_z()
const
56 return this->position.z;
59glm::quat Transform::get_rotation()
const
61 return this->rotation;
64Transform& Transform::set_pos(glm::vec3 new_pos)
66 this->position = new_pos;
92Transform& Transform::translate(
const glm::vec3& translation)
94 this->position = this->position + translation;
99Transform& Transform::rotate(
const glm::quat &rotation)
101 this->rotation *= rotation;
106Transform& Transform::rotate_x(
float degrees)
108 this->rotation *= glm::angleAxis(glm::radians(degrees),
109 glm::vec3(1.0f, 0.0f, 0.0f));
114Transform& Transform::rotate_y(
float degrees)
116 this->rotation *= glm::angleAxis(glm::radians(degrees),
117 glm::vec3(0.0f, 1.0f, 0.0f));
122Transform& Transform::rotate_z(
float degrees)
124 this->rotation *= glm::angleAxis(glm::radians(degrees),
125 glm::vec3(0.0f, 0.0f, 1.0f));
130Transform& Transform::scale(
const glm::vec3& scale)
132 this->scaling = scale;