mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-09 20:08:57 +03:00
Moved quat to forward vector in math helper class
This commit is contained in:
@@ -6,3 +6,8 @@ Quat Nuake::QuatFromEuler(float x, float y, float z)
|
||||
{
|
||||
return Quat(Vector3(Rad(z), Rad(y), Rad(x)));
|
||||
}
|
||||
|
||||
Vector3 Nuake::QuatToDirection(const Quat& quat)
|
||||
{
|
||||
return glm::rotate(glm::inverse(quat), glm::vec3(1.0, 0.0, 0.0));
|
||||
}
|
||||
@@ -18,5 +18,7 @@ namespace Nuake
|
||||
using Matrix4 = glm::mat4;
|
||||
using Matrix3 = glm::mat3;
|
||||
#define Rad(degrees) glm::radians(degrees)
|
||||
|
||||
Quat QuatFromEuler(float x, float y, float z);
|
||||
Vector3 QuatToDirection(const Quat& quat);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include "Engine.h"
|
||||
#include "src/Core/Maths.h"
|
||||
#include "src/Core/FileSystem.h"
|
||||
#include "src/Scene/Components/Components.h"
|
||||
#include "src/Scene/Components/BoxCollider.h"
|
||||
@@ -141,10 +142,13 @@ namespace Nuake {
|
||||
{
|
||||
auto [transform, camera, parent] = view.get<TransformComponent, CameraComponent, ParentComponent>(e);
|
||||
cam = camera.CameraInstance;
|
||||
cam->Translation = transform.GetGlobalPosition();
|
||||
cam->SetDirection(glm::rotate(glm::inverse(transform.GetGlobalRotation()), glm::vec3(1.0, 0.0, 0.0)));
|
||||
camTransform = transform.GetGlobalTransform();
|
||||
|
||||
cam->Translation = transform.GetGlobalPosition();
|
||||
|
||||
const Vector3& forward = QuatToDirection(transform.GetGlobalRotation());
|
||||
cam->SetDirection(forward);
|
||||
|
||||
camTransform = transform.GetGlobalTransform();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user