PDA

View Full Version : gluUnProject?



escozooz
03-10-2002, 11:36 AM
Parameters for gluUnProject are:
GLdouble winX,
GLdouble winY,
GLdouble winZ,
const GLdouble *model,
const GLdouble *proj,
const GLint *view,
GLdouble* objX,
GLdouble* objY,
GLdouble* objZ

When you declare the variables ojbX, objY, objZ before you pass them to the function what type do they have to be?

I have tried:

Gldouble objX; etc.
GLdouble *objX; and neither work.

Jambolo
03-10-2002, 11:42 AM
Your code should look something like this.






GLdouble objX, objY, objX;
...
gluUnproject( ..., &objX, &objY, &objZ );

escozooz
03-10-2002, 12:39 PM
Thanks that worked.

Question? I am using glut and using the mouseFunc to get the winX,winY. Then I call gluUnProject and move and object to objX, objY, objZ.

But the GLUT mouseFunc doesn't provide a z parameter...or does it? Anyway anytime I move my object to the coords generated from gluUnProject the z is always 0. As initialed.

How should I get around this so that the object doesn't always end up right in front of the camera? (due to the z position of 0.)

escozooz
03-10-2002, 12:59 PM
Forget that above. I don' think that unProject does what I think it does.

Furrage
03-11-2002, 06:10 AM
You will have to supply a value for winz that maps to 3D space (0 - 1 inclusive). However, its best to unproject to both the near and far plane, and use the resulting line to intersect with your object (Terrain in this case) and get your z value. There's more in this advance forum topic Selecting Vetrices (http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/005757.html) . The last part gives code you can adapt.