Hi to everyone,
I’m developping a program that can represent the curve of a function. So for do this I’m drawing everything in 2D (I’m using the glOrtho for that). I implemented a zoom effect that is working independantly along the X and Y axis. After that I implemented a translation effect, this helps me to go along the X and the Y axis. This is useful when I’m using the zoom function.
My zoom along X is done by a dynamicaly drawn parallel lines( | | ). I’m drawing these lines with the mouse,and if I’m click between the lines the zoom is done, otherwise the 2 lines disappear. I decided to make some additional functionality and I implemented these 2 lines in a way that I’m able to select one of them and to move it along to X axis.
When I’m selecting one of the lines without any translation along the X axis, the selection works good and I can pick the line and to change it’s position. But if I translate the scene and after that I try to select one of these lines, the selection doesn’t work.
This is the way that I’m calling my functions in the dysplay() :
public void display(GLAutoDrawable drawable) {
zoom.updateH(); //updates some var for the zoom
GL gl = drawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
zoom.zoomingH(drawable); //zoom IN/OUT
gl.glPushMatrix();
gl.glTranslated((scrollX+dragX)/zoomW, (scrollY+dragY)*zoomH, 0); //translation
//used for the gluUnProject to obtain the object coordinates from the mouse coordinates, and to draw after that something on the screen with the mouse
gl.glGetIntegerv(GL.GL_VIEWPORT, v, 0);
gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, m, 0);
gl.glGetDoublev(GL.GL_PROJECTION_MATRIX, p, 0);
//.... some drawing functions
if(!scrollingX && !scrollingY){
if (pickPoint != null){
pickLine(drawable); //used for selection
}
if(curseur || staticCurseur){ //drawCurseur draws the 2 parallel lines: I'm testing inside the function what mode I'have to use (GL_RENDER or GL_SELECT)
dbCursor.drawCurseur(drawable,GL.GL_RENDER);
}
}
gl.glPopMatrix();
}
The pickLine function is written in the same way like in the OpenGL examples.
Do someone has an idea what is the problem and why the selection is working good when there is no translation and when I’m translating the scene I’m no longer able to select one of my lines.
Regards,
Anton