PDA

View Full Version : Arrrrgggh Problem Ive been having for weeks! Help!



blood.angel
02-04-2002, 07:35 PM
This problem has totally eluded me for weeks now. I simply cant find a way in which to solve it.

Right, I have a cube centered at the origin, and a camera that rotates around it (looking at the origin all the time). Now its simple to rotate the camera in the x or y direction I can do that.

But I want it so that when the user wants to rotate the cube 'upwards' I want the camera to move in accordance with the camera orientation, not the axis of the cube. Do you understand what I mean?

Can anyone help me?

marcus256
02-04-2002, 09:01 PM
Have you tried gluLookAt() ?

It greatly simplifies such operations.

blood.angel
02-04-2002, 09:40 PM
Originally posted by marcus256:
Have you tried gluLookAt() ?

It greatly simplifies such operations.

Yeah I use gluLookAt.
But I still cant rotate the camera downwards. It rotates in the world axis. How do I calcul the down ward vector to rotate? Or the right or up for that matter?

marcus256
02-05-2002, 02:07 AM
I'm not sure if I understand it correctly, but have you tried rotating before doing gluLookAt()?

glLoadIdentity()
glRotate()
gluLookAt()

If I remember it correctly, gluLookAt uses the existing matrix (it does not make its own identity matrix), so by rotating the identity matrix, you should simply rotate the camera (and nothing else). (I may be wrong - I have not given this answer much thought)