AllForum

08-29-2012, 08:18 AM

Hello,

Here is what I would like to do :

1- I am rendering a scene with a camera C at position P1.

2- I would like to project some given points as if my camera C was at position P2. Project means compute the coordinates in a function but not to render the points.

3- using the result of step 2- I will move my camera C in a new position.

To do the step 2 I do this in a function :

glMatrixMode(GL_MODELVIEW); // set the mode

glPushMatrix(); // save the current matrix

glLoadIdentity();

gluLookAt(P2.X, P2.Y, P2.Z, NTarget.X, NTarget.Y, NTarget.Z, m_up.X, m_up.Y, m_up.Z); // set the position P2

glGetDoublev(GL_MODELVIEW_MATRIX, ModelView); // retrieve the matrix corresponding to P2

glPopMatrix();

Is this approach (without rendering) valid to obtain the matrix corresponding to position P2 ? I.e. will the call to gluLookAt create the matrix ?

If this approach is correct I will show you what I do to compute the projection because the result is not correct...

Thanks.

Here is what I would like to do :

1- I am rendering a scene with a camera C at position P1.

2- I would like to project some given points as if my camera C was at position P2. Project means compute the coordinates in a function but not to render the points.

3- using the result of step 2- I will move my camera C in a new position.

To do the step 2 I do this in a function :

glMatrixMode(GL_MODELVIEW); // set the mode

glPushMatrix(); // save the current matrix

glLoadIdentity();

gluLookAt(P2.X, P2.Y, P2.Z, NTarget.X, NTarget.Y, NTarget.Z, m_up.X, m_up.Y, m_up.Z); // set the position P2

glGetDoublev(GL_MODELVIEW_MATRIX, ModelView); // retrieve the matrix corresponding to P2

glPopMatrix();

Is this approach (without rendering) valid to obtain the matrix corresponding to position P2 ? I.e. will the call to gluLookAt create the matrix ?

If this approach is correct I will show you what I do to compute the projection because the result is not correct...

Thanks.