I'm currently trying to figure out how to get world coordinates from JOGL - at the moment it only returns x = 0.0, y = 0.0 and z = 0.0, regardless of where I click. What am I doing wrong?
public double[] getMousePosition(int x, int y){ int viewport[] = new int[4]; double modelview[] = new double[16]; double projection[] = new double[16]; float winX, winY, winZ; float posX, posY, posZ; double wcoord[] = new double[4]; gl.glGetDoublev( GL2.GL_MODELVIEW_MATRIX, modelview, 0 ); gl.glGetDoublev( GL2.GL_PROJECTION_MATRIX, projection, 0 ); gl.glGetIntegerv( GL2.GL_VIEWPORT, viewport, 0 ); winX = (float)x; winY = (float)viewport[3] - (float)y; float[] depth = new float[1];
EDIT :: Forgot to mention that I noticed that glu.gluUnproject returns a boolean value, so I assigned it to the logical call test, which returns false.
EDIT2 :: I added another debugging statement - System.out.println (modelview [0]); and also returns 0.0
thanks for the help
James
source share