Jack2606
05-12-2011, 07:25 AM
Hi,
I've just started using gluLookAt() and seem to understand the basics of how it works.. However, i'm struggling to come up with a solution for the following problem using it..
Basically i have a moving sphere that i want the camera to be able to orbit around.. So I tried:
gluLookAt(0, 0, sphereZ + 4, sphereX, sphereY, sphereZ, 0.0, 1.0, 0.0);
glRotatef(angle,0,1,0);
It works perfectly before the sphere moves.. and it will follow the sphere if I do not rotate.. But if i rotate the view slightly it seems to get messed up.. and i'm not sure why.
Basically i want the camera to always be at an equal distance from the sphere in the X and Z (so it orbits around) and i need it to look at the centre of the sphere..
Its probably a very stupid question, but I really can't figure out how to get that to work..
Any help will be appreciated! And please just ask if you need clarification on anything.
Cheers!
I've just started using gluLookAt() and seem to understand the basics of how it works.. However, i'm struggling to come up with a solution for the following problem using it..
Basically i have a moving sphere that i want the camera to be able to orbit around.. So I tried:
gluLookAt(0, 0, sphereZ + 4, sphereX, sphereY, sphereZ, 0.0, 1.0, 0.0);
glRotatef(angle,0,1,0);
It works perfectly before the sphere moves.. and it will follow the sphere if I do not rotate.. But if i rotate the view slightly it seems to get messed up.. and i'm not sure why.
Basically i want the camera to always be at an equal distance from the sphere in the X and Z (so it orbits around) and i need it to look at the centre of the sphere..
Its probably a very stupid question, but I really can't figure out how to get that to work..
Any help will be appreciated! And please just ask if you need clarification on anything.
Cheers!