could someone please explain how to move left and right (strafe) with gluLookAt?

Thanks!

could someone please explain how to move left and right (strafe) with gluLookAt?

Thanks!

Hi !

Not sure what you have problem with, using gluLookAt is just a question of modifing the camera position and what the camera is looking at (and the up vector), What do you mean with “left”, if you have the camera pointing along the Z axis then you can move it left by subtracting a value from the x position in the camera position and the camera target vector.

Mikael

Thanks for your reply,

what i want to be able to do is strafe left or right, relative to my position and where im looking at.

I wish i could give you more information but i can’t think how to explain it more

What you want requires a bit more complex math than OpenGL provides. You really need a general Matrix (or quaternion) library.

However, if you’ve got the FORWARD and UP vectors, the ‘strafing’ vector is just the cross product of the two others.

e.g. Assuming UP is A(x,y,z) and FORWARD is B(x,y,z), strafing is C(x,y,z), strafing can be calculated as follows:

Cx = AyBz - AzBy

Cy = AzBx - AxBz

Cz = AxBy - AyBx

But you really want a meth library sooner rather than later

Great, thanks! i will try it out