0
votes

I started to to something with opengl in pygame, but I'm stuck at the point where gluLookAt takes world coordinates to orient the camera, but I want to move the camera with the mouse, so I have values like "mouse moved 12 pixels to the right".

At the moment I have gluLookAt(player_object.x, player_object.y, player_object.z, lookat_x, lookat_y, -100, 0, 1, 0) but I don't know how to convert the movement of the mouse to these coordinates.

Maybe someone knows the answer or a formula to convert it. (I use python, but I think it's easy to port code or just a formula)

1
@Ripi2 this didn't help me, maybe because i'm VERY new to opengl, and I did't see a gluLookAt in the linked post (and I know nothing about matrices)David Eichelsdörfer
Vectors, matrices and OpenGL "spaces" are a must. You're not going to go a bit futher without them.Ripi2

1 Answers

1
votes

You need to compute the player forward vector: The forward vector is the vector that points in the forward direction seen from the player's eyes - it tells you in which direction the eyes of the player are looking.

The local forward vector (I call it lfw for now) is probably (0,0,1) because you specified the y axis as "up".

The world forward vector (called wfv for now) is: (rotationMatrix * lfw); That is the direction which the player is looking at in world coordinates because you multiplied it with the players rotationMatrix. The final lookAt position is: position + wfv ( means: make one step from position in the forward direction --> yields the point after you took the step.)

Hope this helps a bit