View Full Version : How can I get the vector from camera to object?

11-04-2003, 11:24 AM
I'd like to implement a simple shader that will color my triangles based on the angle between the gaze axisi of the camera and surface normal. I know how to do the normals and get angle between two vectors, but how can I knwo the 'gaze axis' of camera vector? Also how can I querry the current position of opengl camera?

Thank you,

11-07-2003, 11:01 AM
void gluUnProject(x,y,z,modelview,

11-07-2003, 12:54 PM
You can usually use the inverse of your modelview matrix to get the gaze axis and the camera position.

mvi = inverse modelview matrix
camera pos = {mvi[12], mvi[13], mvi[14]}
gaze axis = {mvi[8], mvi[9], mvi[10]}