forked from icaven/glm
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Description
There is no quaternion-based LookAt function. Ideally, this function would take a view direction, and an up vector. Here is one possible implementation, whi²ch assumes that the "front" of the object is towards +Z (should probably be an optional argument) :
vec3 right = cross(direction, desiredUp);
desiredUp = cross(right, direction); // re-orthogonalize
quat rot1 = RotationBetweenVectors(vec3(0.0f, 0.0f, 1.0f), direction);
vec3 newUp = rot1 * vec3(0.0f, 1.0f, 0.0f);
quat rot2 = RotationBetweenVectors(newUp, desiredUp);
return rot2 * rot1;
pfirsich, criptych and sasmaster