Parallel projection and picking [SOLVED]

I am struggling with picking in parallel projection.

My code looks like this:

Vector3f coord = cam.getWorldCoordinates(new Vector2f(e.x, e.y), 0);

Vector3f coord2 = cam.getWorldCoordinates(new Vector2f(e.x, e.y), 1);

Ray ray = new Ray(coord, coord2.subtractLocal(coord).normalizeLocal());





(I just discovered that it's actually suggested that way in another thread)



cam.setDirection(new Vector3f(0,-1,1));

cam.setFrustum(-100.0f, 1000.0f, -50.0f * aspect, 50.0f * aspect,

                -50.0f, 50.0f);



The Object I am trying to hit is centered and has a correct bounding box (checked that) but when I look at the pick results it looks like as if it was the object I am trying to hit is moved 1 or 2 units along the z axis.

What am I doing worng?

Problem was: I am working in SWT and when I send coordinates to getWordlCoordinates I have to flip the Y-coordinate I get from SWT.



Vector3f coord = cam.getWorldCoordinates(new Vector2f(e.x, canvasY-e.y), 0);

Vector3f coord2 = cam.getWorldCoordinates(new Vector2f(e.x, canvasY-e.y), 1);