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
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
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
but I have more objects on scene with different coordinates:
So, you want to have the camera looking directly at an object in your scene, yes?
Well, the first thing you need to do is figure out which object you want the camera to be looking at. A camera cannot be looking directly at two objects at once (unless the camera’s position is fixed to be collinear with the two objects. and then one of them will be obscuring your view of the other). So you need to pick one to be looking at.
gluLookAt takes 3 vectors. In order: the camera’s position in the world, a point in the world that the camera needs to be looking at, and a vector that represents the “up” direction for the camera.
The position of whatever object you’re rotating around needs to be the second of the three vectors you pass into gluLookAt.
Now, if you want to rotate the camera around this point, you must actually do that. You must define a circle centered at the target point, and rotate around that. So your computations of the camera position need to take into account the target point.