Apply rotations in the correct order
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user