PDA

View Full Version : camera orbiting



Penance
05-15-2002, 08:55 AM
I'm interested in orbiting the 'camera' aroud my objects. I know there is gluLookAt, but I am not sure how this is used (i mean i know there are 9 parameters and what each of them is more or less, i just don't know how or where to insert the function into my code!)

basically what I'm trying to acheive is to have the camera be above my objects and to the side (looking down at them) and then have the camera move in a circle around my objects. So it would be like looking at the objects and walking in a circle around them.

Any input or tips appreciated as always.

nexusone
05-15-2002, 11:37 AM
A option that a lot of people use is to not move the camera but move the whole world to simulate the camera.

Here is an example of how move around my world.


glRotatef(WrotateX, 1.0f, 0.0f, 0.0f); rotate world
glRotatef(WrotateY, 0.0f, 1.0f, 0.0f);
glRotatef(WrotateZ, 0.0f, 0.0f, 1.0f);
glTranslatef( 0,0, Worldz); Translate world

glTranslatef(My_Object[(int)j].Curent_point.xyz[0], My_Object[(int)j].Curent_point.xyz[1], My_Object[(int)j].Curent_point.xyz[2]); Translate object in world.

glRotatef(My_Object[(int)j].Rotation_x, 1.0f, 0.0f, 0.0f); Rotate object
glRotatef(My_Object[(int)j].Rotation_y, 0.0f, 1.0f, 0.0f);
glRotatef(My_Object[(int)j].Rotation_z, 0.0f, 0.0f, 1.0f);
Draw_Object();



Originally posted by Penance:
I'm interested in orbiting the 'camera' aroud my objects. I know there is gluLookAt, but I am not sure how this is used (i mean i know there are 9 parameters and what each of them is more or less, i just don't know how or where to insert the function into my code!)

basically what I'm trying to acheive is to have the camera be above my objects and to the side (looking down at them) and then have the camera move in a circle around my objects. So it would be like looking at the objects and walking in a circle around them.

Any input or tips appreciated as always.

lsdi
05-15-2002, 12:07 PM
You alwalys move the whole world. In all graphic engines(directx...) even in linear algebra. Its a very relative question. When you move all the world its supposed that you are moving. Relativity theory.

Sorry about my english.
http://www.opengl.org/discussion_boards/ubb/smile.gif

saian
05-16-2002, 05:13 AM
Isdi,

do you mean that all 3D engine prefers moving all the world instead of a camera in such a situation ?

Is it very more powerful than using gluLookAt ? anyway gluLookAt (as i think) uses transformations as you do when transforming all the world (rotation, translation & scaling). So, what is the real problem if you call it in the first matrix of modelview ?

thanx

coredump
05-16-2002, 05:41 AM
he's just saying that moving the camera X units is identical to moving the entire world -X units. there is no visible difference.

chowe6685
05-16-2002, 06:08 AM
this same argument is going on at the NEHE forum, someone there put it best when he said
you cannot move the camera without moving your moniter. OpenGL doesn't internally have a camera, everything is transformed by the modelview matrix and drawn relative to 0,0,0. all gluLookAt does is setup the modelview matrix to move appropriately

Jambolo
05-17-2002, 10:36 PM
To answer your question...

Call gluLookAt second, right after the glLoadIdentity call.