I'm looking do make an FPS-like camera, but I'm encountering some problems. If I'm first rotating and then translating the camera, everything works fine, but the coordinate system. For example, if I want to go backward with the camera, I have to set the Y coordinate positive. But when I'm translating a model matrix on the Y coordinate in a positive direction, it is moving forward. So somehow the coordinate system is flipped.

When I'm first translating the camera and then rotating, the coordinate system is the same, but now the camera is rotating around the origin, which makes sense, but when I'm looking at examples, everyone does that and no one is complaining about rotating around the origin.

I hope you understand what I mean and I hope you can give me some advice.

  • 1
    \$\begingroup\$ Rotations are allways around the origin! If you want to have something rotated around an arbitrary point you need to do the rotation first and then apply the translation. \$\endgroup\$ – Luis W Aug 6 '13 at 11:56
  • \$\begingroup\$ Yes, I'm aware of that. But the core problem is something else. \$\endgroup\$ – Liess Jemai Aug 6 '13 at 12:04
  • 1
    \$\begingroup\$ Can you tell us a little more about how you do your math and create your matrices and how you multiply and pass them to the renderer? This is probably a problem with how you setup your matrices so that would be useful information. \$\endgroup\$ – Luis W Aug 6 '13 at 12:15
  • \$\begingroup\$ I'm using GLM. I set the view matrix in an camera class. I'm using glm::rotate three times for X, Y and Z and then I multiply them by the translation matrix(glm::translate). Then I'm multipling the Model-, View- and Projection matrices in the shader. \$\endgroup\$ – Liess Jemai Aug 6 '13 at 12:25
  • \$\begingroup\$ "I want to go backward with the camera, I have to set the Y coordinate positive" When you have an unrotated camera the Y-Axis usually points up, X points to the right and you look along the negative Z-axis. Of course this is just depending on how your matrices look like but that´s GLSL standart and GLM follows the same convention for it´s inbuilt functions. \$\endgroup\$ – Luis W Aug 6 '13 at 13:32

To me, this sounds like you're thinking about it the wrong way. Translating the camera to a positive direction "moves the world forward", not the camera backwards, as basically the world is multiplied by the camera matrix. So when you translate an entity forward, it actually goes forward, so the direction is the same.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.