Changing the camera look at

Hi,

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

Doron

If you are using fixed functionality, gluLookAt() is the simplest way for that.
http://www.opengl.org/sdk/docs/man/xhtml/gluLookAt.xml

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.

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

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.

Hi Aleksander

That worked beautifully

thank you very much