View Full Version : Rotating gluLookAt

Swiftless

04-18-2005, 08:04 PM

Hi,

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.

Thankyou.

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:

x=orbit_radius*cos(angle)

z=orbit_radius*sin(angle)

and just increase or decrease the angle.

If you want to roll the camera you need to rotate the up vector.

Swiftless

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?

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/) .

Swiftless

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.

Just by changing the LookAt arguments. Do some maths in order to achive your goals.

Swiftless

04-19-2005, 06:41 AM

Thats the thing, I do not know which Maths to do...

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.

Swiftless

04-19-2005, 06:58 AM

OK, Thanks

Swiftless, HI:

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

Originally posted by Swiftless:

OK, Thanks

Swiftless

04-19-2005, 09:25 PM

I already have strafe working perfectly, the problem was and currently still is, rotating the view.

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.