I really have an issue with mouseclicks in an isometric view. Simply i have a flat map, and, like i said, a camera in an isometric view. Now when i click in the window i want to get the Coordinates where i clicked on the map. Any Help?
A:
Sorry, but no.
Any given canvas point is an infinite length line of isometric (x, y, z) coordinates.
The best you can do is use the LWJGL Mouse class to move the viewpoint the same direction as you move the mouse.
Gilbert Le Blanc
2010-06-29 13:40:21
+1
A:
actually, i figured it out.
int winX = ... //the x coordinate of the Click, given Parameter
int winY = ... //the y Coordinate of the Click, given Parameter
FloatBuffer winZ = BufferUtils.createFloatBuffer(1); //the x coordinate of the click, will be calculated
FloatBuffer pos = BufferUtils.createFloatBuffer(3); // the final position of the click
FloatBuffer modelview = BufferUtils.createFloatBuffer(16);
FloatBuffer projection = BufferUtils.createFloatBuffer(16);
IntBuffer viewport = BufferUtils.createIntBuffer(16);
GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);
GL11.glGetFloat(GL11.GL_PROJECTIONMATRIX, projection);
GL11.glReadPixels(winX, winY, 1,1, GL11._GL_DEPTH_COMPONENT, GL11.GL_FLOAT, winZ) //calculate the Z Coordinate of the Click
GLU.gluUnProject((float)(winX), (float)(winY), (float)(winZ.get(0)), modelview, projection, viewport, pos); //Calculating the 3D Position of the click, saved in pos
Now since you have the 3D Coordinates you can do some simple vector calculation and collision detection to get the point you clicked on
Simiil
2010-06-30 07:02:55
You don't need to use glReadPixels, just assume the Z component is 0.5 or so (i.e. half-way between the near and far clip plane) and you'll get the same result.
Dean Harding
2010-06-30 07:22:18