mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-09 20:08:57 +03:00
Fixed wrong camera rotation when global rotation is set
This commit is contained in:
@@ -4,10 +4,5 @@ using namespace Nuake;
|
||||
|
||||
Quat Nuake::QuatFromEuler(float x, float y, float z)
|
||||
{
|
||||
// Taken from: https://gamedev.stackexchange.com/questions/13436/glm-euler-angles-to-quaternion
|
||||
Quat QuatAroundX = glm::angleAxis(glm::radians(x), Vector3(1.0, 0.0, 0.0));
|
||||
Quat QuatAroundY = glm::angleAxis(glm::radians(y), Vector3(0.0, 1.0, 0.0));
|
||||
Quat QuatAroundZ = glm::angleAxis(glm::radians(z), Vector3(0.0, 0.0, 1.0));
|
||||
|
||||
return QuatAroundZ * QuatAroundX * QuatAroundY;
|
||||
return Quat(Vector3(Rad(z), Rad(y), Rad(x)));
|
||||
}
|
||||
|
||||
@@ -17,6 +17,6 @@ namespace Nuake
|
||||
using Color = glm::vec4;
|
||||
using Matrix4 = glm::mat4;
|
||||
using Matrix3 = glm::mat3;
|
||||
|
||||
#define Rad(degrees) glm::radians(degrees)
|
||||
Quat QuatFromEuler(float x, float y, float z);
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace Nuake {
|
||||
auto [transform, camera, parent] = view.get<TransformComponent, CameraComponent, ParentComponent>(e);
|
||||
cam = camera.CameraInstance;
|
||||
cam->Translation = transform.GetGlobalPosition();
|
||||
cam->SetDirection(Vector3(Vector4(0, 0, -1, 0) * transform.GetGlobalTransform()));
|
||||
cam->SetDirection(glm::rotate(glm::inverse(transform.GetGlobalRotation()), glm::vec3(1.0, 0.0, 0.0)));
|
||||
camTransform = transform.GetGlobalTransform();
|
||||
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user