PDA

View Full Version : perspective



enisozgur
05-18-2002, 07:13 AM
I want the draw point where click my mouse
(perpective mode)
but don't draw correctly
I suppose to arise from "perspective"
what will I do
thanks.

mikael_aronsson
05-18-2002, 04:43 PM
Hi !

Sorry, I didn't get exactly what the problem is, do you have an application where you want to plot points at the (mouse) cursor position in perspective mode ?

If that is the case then it's a bit tricky as you need to get the correct Z value for it.

You could use gluUnProject for it, give it the X and Y coordinate of the mouse position (don't forget to flip Y) and a valid Z value (0.5 would be a good start), and gluUnProject will return a valid 3D coordinate that you can use to plot a point at that position.

Mikael

enisozgur
05-18-2002, 11:45 PM
Originally posted by mikael_aronsson:
Hi !

Sorry, I didn't get exactly what the problem is, do you have an application where you want to plot points at the (mouse) cursor position in perspective mode ?

If that is the case then it's a bit tricky as you need to get the correct Z value for it.

You could use gluUnProject for it, give it the X and Y coordinate of the mouse position (don't forget to flip Y) and a valid Z value (0.5 would be a good start), and gluUnProject will return a valid 3D coordinate that you can use to plot a point at that position.

Mikael

-------------------------

...
glFrustum( -100, 100, -100, 100, 100, 300 );
...
gluLookAt( 0.0, 0.0, 100.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 );

...

//mouse click event
realy = viewport[3] - (GLint) Y - 1;

//wx,wy,wz global values
gluUnProject ((GLdouble) X, (GLdouble) realy, ? ,mvmatrix, projmatrix, viewport, &wx, &wy, &wz);
OpenGLPanel1->Repaint ();
.....
//paint routine
glBegin(GL_POINTS);
glVertex3d(wx,wy,wz);
glEnd();
....

for example ;I want plot Z -50 how do I select in gluUnProject windowZ value.Why windowZ value 0 between 1