Original Post
Hi everybody!
I''m trying to make a 3D modelling program in Open GL. And my problem is that i can''t select vetices on the screen using the mouse.
What i want to do is, convert the mouse coordinates to a vertex so i can compare that vertex with all vertices in the 3d object. And if it is a close match to any vertex in the 3d object then that vertex will be selected. You know what i meen...
This is the code im working with... It seems to work when I scale my 3d object but it does not work when i have rotated my object. Why?
glGetDoublev( GL_PROJECTION_MATRIX, projectionMatrix );
glGetDoublev( GL_MODELVIEW_MATRIX, modelviewMatrix );
glGetIntegerv( GL_VIEWPORT, viewport );
gluProject( x,
y,
z,
modelviewMatrix,
projectionMatrix,
viewport,
&winX,
&winY,
&winZ );
gluUnProject( mouseX,
mouseY,
winZ,
modelviewMatrix,
projectionMatrix,
viewport,
&x,
&y,
&z );
// Thanx, Peter....