Answer the question
In order to leave comments, you need to log in
How to correctly implement lookat function for camera in opengl using quaterions?
How to implement a camera function to look at a point using quaternions using the glm library? Right now I have the following implementation:
glm::vec3 front = point - Position;
if (front == vec3(0.0f, 0.0f, 0.0f))
{
this->rotation = vec3(0.0f,0.0f,0.0f);//euler rotation
updateCameraVectors();
}
else {
front = glm::normalize(front);
quat orient = quatLookAt(front, vec3(0.0f,1.0f,0.0f)); // quaterion rotation
vec3 rot = (glm::eulerAngles(orient) * 3.14159f / 180.f); //euler rotation
this->rotation = vec3(glm::degrees(rot.x), glm::degrees(rot.y), glm::degrees(rot.z));
updateCameraVectors();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question