I got this problem here with glu.gluunproject
my main objective here is load a mesh, and just to draw lines in front of it… the problem is that I cant seems to be able to draw the lines infront of the loaded mesh. It always appear behind the mesh as shown in the picture.
I use glu.gluunproject to get the object coordinates but some how i reaslised that its not working properly.
below is the code for mi to calculate the object coordinate
I do not know what value should I input for z.
Since im trying to draw in front of the mesh, i tried getting the max z value of the mesh. which is 55.74 but den i input this value into the glu.gluunproject, its seems so wrong where the value returned after the converstion is (110.0…).I suppose to be converted to a value abt 1.
public void calObjectCoor(GL gl,float mousex,float mousey,float z) {
float x = mousex, y = mousey;
gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, mvmatrix, 0);
gl.glGetDoublev(GL.GL_PROJECTION_MATRIX, projmatrix, 0);
/* note viewport[3] is height of window in pixels */
realy = viewport[3] - (int) y - 1;
//System.out.println("Coordinates at cursor are (" + x + ", " + realy);
glu.gluUnProject((double) x, (double) realy, z, //
mvmatrix, 0,
projmatrix, 0,
viewport, 0,
wcoord, 0);
}