The best way to make the camera move and rotate

I am studying an OpenGL programming program and I am stuck on how to implement it, so the camera follows the mouse pointer. As in the fps game, you want to see where your mouse has pointed, but I can’t find a good solution for this while I am moving. I thought about saving one matrix for movement, for example, walking and shooting, using quaternions to handle rotation. Then turn the quaternion into a rotation matrix, load the identifier for the model representation matrix and draw this matrix from both matrices.

Of course, there are some problems with this, for example, which matrix should we use in the first multiplication, and the code will be ugly.

So, I am wondering if anyone has a good solution to solve this issue, so I do not need to figure out which matrix to use in the first place, and what gives a cleaner code.

+3
source share
2 answers

Save your camera viewing information as a position vector, vector image, and pointer vector (think about pointing with your thumb: your finger is a vector image, and your thumb is an up-vector). Keep these vectors normalized and at 90 degrees to each other. You should be able to see that these three vectors are sufficient to represent the position and orientation of the camera.

You can use these vectors to convert world coordinates to camera coordinates:

  • Translate to-position;
  • (- '' Y) - ( y);
  • - ( - z).

(, ).

, :

  • , - (, , -, - y).
  • /, -, - (- "cross" -).
+5

, 3D- Irrlicht FPS , , , , , .

, FPS Irrlicht, Irrlicht ; , , :)

0

Source: https://habr.com/ru/post/1702239/


All Articles