Super-K

01-23-2002, 07:29 PM

I have a 3D point (Point1) and I have a 2D screen coodinate.

I want to take the current camera view angle as a plane normal and "push" the plane back along that normal until it touches Point1. I then want to project a line from my 2D coordinates along that normal until it intersects the plane. The resulting 3D coodinate of that last intersection is what I need.

I really thought I could gluProject Point1 to get the screen Z. Then pluUnProject my 2D coordinates using that Z and find what I needed. I haven't had much luck getting anything useful from UnProject though.

A short version of what my code kinda looks like:

gl:matrixMode(?GL_PROJECTION),

gl:loadIdentity(),

glu http://www.opengl.org/discussion_boards/ubb/tongue.giferspective(45.0, W/H, 0.25, 1000.0),

gl:matrixMode(?GL_MODELVIEW),

gl:loadIdentity(),

gl:translatef(0.0, 0.0, -Dist),

gl:rotatef(Elevation, 1.0, 0.0, 0.0),

gl:rotatef(Azimuth, 0.0, -1.0, 0.0),

ModelMatrix = gl:getDoublev(?GL_MODELVIEW_MATRIX),

ProjMatrix = gl:getDoublev(?GL_PROJECTION_MATRIX),

glu:unProject(ScreenX,ScreenHeight-ScreenY,Zdepth,ModelMatrix,ProjMatrix,ViewPort),

I can post more, but I'm wondering if there is something wrong with the way I'm rotating/translating, causing the weird values I get back from UnProject.

Thanks for any info!

I want to take the current camera view angle as a plane normal and "push" the plane back along that normal until it touches Point1. I then want to project a line from my 2D coordinates along that normal until it intersects the plane. The resulting 3D coodinate of that last intersection is what I need.

I really thought I could gluProject Point1 to get the screen Z. Then pluUnProject my 2D coordinates using that Z and find what I needed. I haven't had much luck getting anything useful from UnProject though.

A short version of what my code kinda looks like:

gl:matrixMode(?GL_PROJECTION),

gl:loadIdentity(),

glu http://www.opengl.org/discussion_boards/ubb/tongue.giferspective(45.0, W/H, 0.25, 1000.0),

gl:matrixMode(?GL_MODELVIEW),

gl:loadIdentity(),

gl:translatef(0.0, 0.0, -Dist),

gl:rotatef(Elevation, 1.0, 0.0, 0.0),

gl:rotatef(Azimuth, 0.0, -1.0, 0.0),

ModelMatrix = gl:getDoublev(?GL_MODELVIEW_MATRIX),

ProjMatrix = gl:getDoublev(?GL_PROJECTION_MATRIX),

glu:unProject(ScreenX,ScreenHeight-ScreenY,Zdepth,ModelMatrix,ProjMatrix,ViewPort),

I can post more, but I'm wondering if there is something wrong with the way I'm rotating/translating, causing the weird values I get back from UnProject.

Thanks for any info!