3#define GLM_ENABLE_EXPERIMENTAL
6#include <glm/gtc/quaternion.hpp>
7#include <glm/gtx/quaternion.hpp>
21 glm::vec3 direction = glm::normalize(target - eye);
22 glm::vec3 right = glm::normalize(glm::cross(up, direction));
23 glm::vec3 newUp = glm::cross(direction, right);
25 glm::mat3 rotationMatrix;
26 rotationMatrix[0] = right;
27 rotationMatrix[1] = newUp;
28 rotationMatrix[2] = direction;
30 return glm::quat_cast(rotationMatrix);
43 glm::quat pitchQuat = glm::angleAxis(pitch, glm::vec3(1.0f, 0.0f, 0.0f));
44 glm::quat yawQuat = glm::angleAxis(yaw, glm::vec3(0.0f, 1.0f, 0.0f));
46 return glm::normalize(yawQuat * current * pitchQuat);
57 return glm::normalize(rotation * glm::vec3(1.0f, 0.0f, 0.0f));
68 return glm::normalize(rotation * glm::vec3(0.0f, 1.0f, 0.0f));
79 return glm::normalize(rotation * glm::vec3(0.0f, 0.0f, 1.0f));
Definition CameraManager.hpp:12
glm::vec3 GetUpVector(const glm::quat &rotation)
Get the up vector from a quaternion rotation.
Definition CameraUtils.hpp:66
glm::quat RotateQuaternion(const glm::quat ¤t, float pitch, float yaw)
Apply pitch and yaw rotation to a quaternion.
Definition CameraUtils.hpp:41
glm::quat ComputeLookAtQuaternion(const glm::vec3 &eye, const glm::vec3 &target, const glm::vec3 &up)
Compute a quaternion that represents a "look at" rotation.
Definition CameraUtils.hpp:19
glm::vec3 GetRightVector(const glm::quat &rotation)
Get the right vector from a quaternion rotation.
Definition CameraUtils.hpp:55
glm::vec3 GetForwardVector(const glm::quat &rotation)
Get the forward vector from a quaternion rotation.
Definition CameraUtils.hpp:77