View Full Version : Changing the camera look at

07-30-2010, 07:33 AM

I have a scene that as a robot with a sphere as its head. i want to be able to change the camera as if it were looking through the eyes of the robot.

Is there an easy way of telling where the center of the sphere is and how to locate the camera in that way

Thank you


07-30-2010, 08:55 AM
If you are using fixed functionality, gluLookAt() is the simplest way for that.

If you are using shaders, take a look at the implementation of glLookAt() function, and build up your model-view matrix on the same way, before sending it to the vertex shader as a value of some uniform variable.

07-30-2010, 10:08 AM
Thank you for the reply,

The problem i'm having is with the function gluLookAt and if it's possible to move and rotate the object and the camera the same way , to make it look like the viewing is from the object eye

thank you

07-30-2010, 10:25 AM
Then you don't have to move/rotate object that represents a head. In fact, you have to move/rotate the whole scene (except the body) according to the head movements. Be sure that you correctly understand model/view transformations.

07-31-2010, 09:49 AM
Hi Aleksander

That worked beautifully

thank you very much