I am currently working on a some sort of editor. The terrain of this editor is a map built out of tiles (squares).
When i click my GLJPanel i sent a mouseevent because I want to check if I click on a tile.
So basicly I want to convert my X and Y mouse coordinate to Coordinate in the XZ plane (since Y axis is the one pointing up).
So far I tried to do this using glu.gluUnProject but i have no success doing so
During init methode of GLEventListener
this.viewport = IntBuffer.allocate(4);
this.modelview = FloatBuffer.allocate(16);
this.projectionview = FloatBuffer.allocate(16);
Whenever I reshape my window I update the buffers
Every time a frame is drawn i update modelview buffer in display method
This is the code i execute when i want to convert the mouse to XZ plane coordinates
float winX, winY;
winX = (float)this.pickX;
winY = (float)this.pickY;
winY = (float)this.viewport.get(3) - winY - 1;
FloatBuffer projectedPositions = FloatBuffer.allocate(3);
boolean succes = new GLU().gluUnProject(winX, winY, 0.0f, this.modelview, this.projectionview, this.viewport, projectedPositions);
System.out.println(projectedPositions.get(0)+" "+projectedPositions.get(1)+" "+projectedPositions.get(2)+" "+succes);
Am I using the wrong method or am I passing along the wrong arguments?
When i see at least 10 tiles on my screen, each tile = 1.0f x 1.0f the difference between most left and most right tile on my screen is maybe 0.1f so something is obviously going wrong
Thx for any help