|
Hi,
I'm tracking a bug in an application since hours and I wonder if someone may have an idea on a problem which seems hard to debug. I'm using a method every drawing cycle, in a valid GLContext, for updating/transforming mouse coordinates in World coordinates system :
___________________________________________________________________
public Point2d getWorldCoords(int x, int y) {
Point2d coords = new Point2d();
int viewport[] = new int[4];
double modelViewMatrix[] = new double[16];
double projectionMatrix[] = new double[16];
double projectedCoords[] = new double[3];
double unprojectedCoords[] = new double[3];
int realY;
this.gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport, 0);
this.gl.glGetDoublev(GL2.GL_MODELVIEW_MATRIX, modelViewMatrix, 0);
this.gl.glGetDoublev(GL2.GL_PROJECTION_MATRIX, projectionMatrix, 0);
realY = viewport[3] - (int) y - 1;
this.glu.gluProject(this.currentCamera.getX(), this.currentCamera.getY(), 0, modelViewMatrix, 0, projectionMatrix, 0, viewport, 0, projectedCoords, 0);
this.glu.gluUnProject((double) x, (double) realY, projectedCoords[2], modelViewMatrix, 0, projectionMatrix, 0, viewport, 0, unprojectedCoords, 0);
coords.setXY((float) unprojectedCoords[0], (float) unprojectedCoords[1]);
// TODO : Debug
System.out.println(".getWorldCoords(): viewport: " + viewport[0] + ":" + viewport[1] + ":" + viewport[2] + ":" + viewport[3]);
System.out.println(".getWorldCoords(): mouse x: " + x + " y: " + y);
System.out.println(".getWorldCoords(): world x: " + coords.getX() + " y: " + coords.getY());
System.out.println(".getWorldCoords(): real y: " + realY);
return coords;
}
___________________________________________________________________
viewport, mouse coordinates, real y are ok but World coordinates are always (0.0, 0.0).
I gonna try to get the old matrix values from using 1.1.1 for compare them to new values using JOGL2 but I need to reverse a lot of code for that so any clue is welcome before I'll do that :) if someone have an idea on this or if someone knows a significative change in GLU which may do that (cause I think the "problem" is in GLU).
Thanks in advance.
|