# The Industry's Foundation for High Performance Graphics

1. ## gluLookAt around circle

Here is image: http://img861.imageshack.us/i/camk.jpg/

I would like to circle camera around object on scene. Circle ray = 100.
I have that code but the movement camera is strange:
Code :
```float rotateValueX = 0;
--------------------
if (rotateValueX >= 360) rotateValueX = 0;
else rotateValueX += 1;

float xCircle = 100 * cos(PI * rotateValueX / 180);
float yCircle = 100 * sin(PI * rotateValueX / 180);
gluLookAt(xCircle, 0, 100,  0, 0, 0,  0, 1, 0);```

And if I change
gluLookAt(xCircle, 0, 100, 0, 0, 0, 0, 1, 0);

to
gluLookAt(xCircle, 0, yCircle, 0, 0, 0, 0, 1, 0);

it is also bad because once object is far and another is near

2. ## Re: gluLookAt around circle

you really don't know ?

lols?

4. ## Re: gluLookAt around circle

it's not funny :P

5. ## Re: gluLookAt around circle

ok well with glulookat()
the first 3 numbers make up the coordinate where the camera sits
the next 3 numbers make up the coordinate where you want the camera to look at
or you can think of it as where the object you are trying to look at sits
the last three numbers is the camera up
so normally up is x=0, y=0, z=1
but sometimes people put y as up
you can try both and see what happens and look at the code
and see which way is up in your code
it helps to draw colored cubes or lines to help you orient yourself in the opengl world

ok so to circle around the the object you have to set the camera view which is your glulookat() numbers 4 5 6 to the coordinates of your object
then the camera position glulookat() numbers 1 2 3 would be the numbers from the formula

6. ## Re: gluLookAt around circle

you cant have gluLookAt(xCircle, 0, yCircle, 0, 0, 0, 0, 1, 0);
because ur telling the camera to make 2 circles in different directions at the same time so it will probably start flashing the image

gluLookAt(xCircle, 0, 100, 0, 0, 0, 0, 1, 0);
this one cicles around the center of the world but its 100 units above the object looking down at it so i would make 100 to 0 here
and change the last 3 numbers to 0,0,1 because the way you have it the camera is laying on its side

7. ## Re: gluLookAt around circle

People I am close but still need Your help !

It works great if I comment this line in below code:
glTranslatef(10, 30, -135);
but I need this translation to cube so what can I do ?

Code :
```        float xCircle = rotateValueZ * cos(PI * rotateValueX / 180);
float zCircle = rotateValueZ * sin(PI * rotateValueX / 180);

gluLookAt(xCircle, 0, zCircle, 0, 0, 0, 0, 1, 0);

glPushMatrix();
//glTranslatef(10, 30, -135); //without this it works great
glRotatef(90, 0, 0, 1);
glScaled(0.2, 1, 0.2);
glutSolidCube(30);
glPopMatrix();```

8. ## Re: gluLookAt around circle

omg wut r u doing?
fine if u want to move ur weird cube to 10, 30, -135
then u need to move ur camera view to
gluLookAt(xCircle, 0, zCircle, 10, 30, -135, 0, 1, 0);
once u grasp how the lookat works you will see what your numbers should be
remember the lil kid in the matrix
be that kid!
throw the spoon in neos face lol jk

9. ## Re: gluLookAt around circle

Hm........ but I have more objects on scene with different coordinates:

Code :
```        glPushMatrix();
glTranslatef(10, 30, -135);

glRotatef(90, 0, 0, 1);
glScaled(0.2, 1, 0.2);
glutSolidCube(30);
glPopMatrix();

glPushMatrix();
glTranslatef(40, 10, -100);

glRotatef(90, 0, 0, 1);
glScaled(0.2, 1, 0.2);
glutSolidCube(30);
glPopMatrix();

........```

so I can't write in gluLookAt() 10, 30, -135 - what is the solution in that case ?

10. ## Re: gluLookAt around circle

then maybe u would focus in the center of all the objects?
zoom out perhaps?
this is where it becomes YOUR world

camera.pos ( o-)-------------------> camera.view

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•