Using OpenGL and the GLM matrix library, I want to translate my camera relative to the world coordinate system. This requires me to compute the necessary view matrix. To initialise the view matrix, I used:
view_matrix = glm::lookAt(eye, centre, up);
eye = (0, 0, 10),
centre (0, 0, 0), and
up = (0, 1, 0). Suppose I want to now translate the view matrix by 5 unites in the camera's y-direction, i.e. to move upwards relative to the model. I tried:
view_matrix = glm::translate(view_matrix, glm::vec3(0, 5, 0));
This works fine at first, because the view and world coordinate systems are aligned. However, if I then rotate my camera a bit, and then perform this translation, it no longer works. Instead, it moves the camera along the world coordinate system, rather than the camera coordinate system.
So what I need to do, is to find the vector which represents the "up" direction of the camera, and then translate along this vector. This is similar to the inverse of the
glm::lookAt(eye, centre, up) function.
In summary: Is it possible to find the "up" vector of the view matrix using the GLM library?