# First Person View - Aeroplane

I have implemented rotations for an airplane using quaternions. Now I want a First Person view where the camera also rotates along with the airplane. I have translated the camera position to be inside the cockpit, but I am not sure how i can change my camera’s front and up vector. I know i can apply hierarchical rotations to objects by multiplying the parent’s model matrix, but I am not sure how i can get a rotated front, up or right vectors. Could someone help please?

Take the plane’s matrix (rotation and translation), optionally append a translation (if you want the camera origin to be somewhere other than the plane’s origin) and invert it. This is your view matrix.

With legacy OpenGL, the view matrix was typically generated by relying upon a) that (A·B·C)-1=C-1·B-1·A-1 and b) that the primitive matrix operations (translate, rotate, scale) can be trivially inverted (negate the offsets, invert the scale factors, or negate the rotation angle, respectively). So whatever transformations would be required to place and orient an object at the camera, the inverse can be obtained by applying the inverse transformations in the opposite order. All of which was necessary because neither OpenGL itself nor GLU provided a function to invert a matrix (although GLU had this functionality internally to implement gluUnProject).

With GLM (or similar), it’s simpler to just generate the appropriate camera (eye-to-world) matrix then invert it to get the view (world-to-eye) matrix. This also makes it straightforward to attach a camera to any object, or to position a camera using the same mechanisms used to position objects.

[QUOTE=GClements;398073]Take the plane’s matrix (rotation and translation), optionally append a translation (if you want the camera origin to be somewhere other than the plane’s origin) and invert it. This is your view matrix.

With legacy OpenGL, the view matrix was typically generated by relying upon a) that (A·B·C)-1=C-1·B-1·A-1 and b) that the primitive matrix operations (translate, rotate, scale) can be trivially inverted (negate the offsets, invert the scale factors, or negate the rotation angle, respectively). So whatever transformations would be required to place and orient an object at the camera, the inverse can be obtained by applying the inverse transformations in the opposite order. All of which was necessary because neither OpenGL itself nor GLU provided a function to invert a matrix (although GLU had this functionality internally to implement gluUnProject).

With GLM (or similar), it’s simpler to just generate the appropriate camera (eye-to-world) matrix then invert it to get the view (world-to-eye) matrix. This also makes it straightforward to attach a camera to any object, or to position a camera using the same mechanisms used to position objects.[/QUOTE]

This is exactly what I was missing. Thanks a ton!!!