Having taken a basic CG course, I remember that transformations are relative, so rotating the camera is identical to rotating the view in the opposite direction. Right now I want to implement camera rotation using the mouse. In OpenGL, I can see the family of functions called lookAt() as implemented by the various libraries. However, those take vectors for camera positions. I feel it is incorrect to calculate the vector for camera position when we can rotate the world with a matrix transformation, e.g. using quaternions (as implemented handily by Qt5 or GLM). Thus, is it a correct and adopted solution to apply a transformation to the model matrix as opposed to the view matrix in the following line of code:

gl_Position = proj * view * model * vec4(position, 0.0, 1.0);

ref. https://open.gl/transformations, subsection "Going 3D"?

Or, should I rather apply a rotation transformation as defined by a matrix received using quaternion algebra analogous to the solution above, but, this time around, to the matrix position vector? Will those be identical? (My common sense tells me they will only be identical if the camera is pointing to 0 and the object is located at point 0 - but I lack the required knowledge about transformations yet.)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.