View Full Version : Rotating gluLookAt

04-18-2005, 08:04 PM
In my little application I am using gluLookAt to simulate a camera. I have it working so that it can strafe left and right, move forward and backward easily enough, but I cannot figure out how to rotate the position on the x axis (left and right) it is looking at, so that it rotates the 'camera' as such.

04-18-2005, 09:04 PM
I'm not sure I understand what you want. You want to orbit around an object? Or roll the camera?
If you want to orbit, then the camera moves on a plane (xz assuming that y is the up vector) not on an axis and you will have to use sin and cos functions:
and just increase or decrease the angle.
If you want to roll the camera you need to rotate the up vector.

04-18-2005, 09:32 PM
I am thinking sort of like a First Person Shooter, where you can 'turn' the character left and right, by swivelling the camera around.

Can you explain the Up Vector please?

04-18-2005, 09:56 PM
Originally posted by Swiftless:
Can you explain the Up Vector please?:eek: Vector that points upwards?!?!?!
That\'s what Google found about gluLookAt (http://www.google.com/search?sourceid=navclient&ie=UTF-8&rls=GGLD,GGLD:2004-36,GGLD:en&q=glulookat)
The Red Book (http://www.opengl.org/documentation/red_book_1.0/)
NeHe Tutorials (http://nehe.gamedev.net/default.asp)
FireStorm Tutorials (http://www.firestorm.go.ro/) .

04-19-2005, 06:10 AM
So how would I rotate the 'camera' with gluLookAt? I have done google searches but they only talk about using the Translate and Rotate functions.

04-19-2005, 06:34 AM
Just by changing the LookAt arguments. Do some maths in order to achive your goals.

04-19-2005, 06:41 AM
Thats the thing, I do not know which Maths to do...

04-19-2005, 06:51 AM
First try to apply the maths you already know. I guess you know how to rotate a point in a 2D plane.

And as that's the thing, maybe the maths and algorithm forum will best fit your needs.

04-19-2005, 06:58 AM
OK, Thanks

04-19-2005, 08:27 AM
Swiftless, HI:

If we want strafe, we can change eyex/y/z in gluLookAt to get that effect.

Originally posted by Swiftless:
OK, Thanks

04-19-2005, 09:25 PM
I already have strafe working perfectly, the problem was and currently still is, rotating the view.