Apply rotations in the correct order

This commit is contained in:
Dane Johnson committed 2021-01-20 22:17:33 -06:00
1 parent 4f1f04a78d
commit fdeff15bd6
2 files changed
+10 -6

No files matched your search

+6 -3
View File
@@ -27,8 +27,11 @@ void Transform::Translate(cfloat x, cfloat y, cfloat z) {
Vector3 Transform::Forward() {
Vector3 forward(0.0f, 0.0f, -1.0f);
Matrix mat(1.0f);
mat = glm::rotate(mat, this->rotation.x, Vector3(1.0f, 0.0f, 0.0f));
mat = glm::rotate(mat, this->rotation.y, Vector3(0.0f, 1.0f, 0.0f));
mat = glm::rotate(mat, this->rotation.z, Vector3(0.0f, 0.0f, 1.0f));
return mat * glm::vec4(forward, 1.0f);
mat = glm::rotate(mat, this->rotation.y, Vector3(0.0f, 1.0f, 0.0f));
mat = glm::rotate(mat, this->rotation.x, Vector3(1.0f, 0.0f, 0.0f));
return glm::vec3(mat * glm::vec4(forward, 1.0f));
}