Re: mouse input
Posted by
Irene Tang on
Feb 25, 2016; 1:26am
URL: https://forum.jogamp.org/SOLVED-mouse-input-tp3504609p4036336.html
Hello,
What I aim to do is to select a part of the 3D in the original picture by a rectangle, then I can get the TVD information of that selected part.

Now, I can draw a rectangle according to the mouse click and drag, see add-a-rectangle picture.

But it isn't in the same plane with the selected part.
About the first email. I was using the immediate mode to draw a rectangle. May be I didn't make myself understood. The following matrix transformation is how to transform a model coordinate system to a screen coordinate system. But the points generated in mouse click and drag are based on screen coordinate system not model coordinate system. So if I use
gl2.glBegin(GL2.GL_QUADS);
gl2.glVertex2f(mouseDownX, mouseDownY);
gl2.glVertex2f(mouseDownX, mouseMoveY);
gl2.glVertex2f(mouseMoveX, mouseMoveY);
gl2.glVertex2f(mouseMoveX, mouseDownY);
gl2.glEnd();
, which means regarding the screen values as model values. That would be wrong. Later, I figured out a way. First I set the modelview matrix and projection matrix to identity matrix, then please see calculate picture.

Am I right in this way?