hi,
i’m using glm for all the math, and i represent objects in “transform” objects:
struct Transformation
{
glm::vec3 Position;
glm::quat Rotation;
glm::mat4 Matrix() const { return glm::translate(Position) * glm::toMat4(Rotation); }
glm::mat4 View() const { return glm::inverse(Matrix()); }
};
from OpenAL (sound API), i get 2 directions for the “listener” (which is essentially the camera): forward and up dirction. the way i’m getting the “Transformation” is:
glm::quat al::listener::Orientation()
{
ALfloat orientation[6] = { 0 };
alGetListenerfv(AL_ORIENTATION, orientation);
/* get directions */
glm::vec3 forward(orientation[0], orientation[1], orientation[2]);
glm::vec3 up(orientation[3], orientation[4], orientation[5]);
/* get view matrix */
glm::mat4 view = glm::lookAt(glm::vec3(0, 0, 0), forward, up);
/* invert view matrix */
glm::mat4 transform = glm::inverse(view);
/* return rotation */
return glm::toQuat(transform);
}
i’m getting around the problem using matrices, but is there an easier / faster way to get the rotation somehow ??
thanks for any advice !!