What if I don't want the first object in the direction of my click but the one behind it?
In my model I have some objects which are transparent (like glasses); if the user clicks these ones I have to ignore them and try to pick another object behind the clicked one in the same direction of the click (if this one is transparent again the one behind, until I pick a non-transparent object or nothing)
I tried with the following code but did not succeed; the app continues to pick always the same object:
SimpleVector dir = Interact2D.reproject2D3D(camera, frameBuffer, screenX, screenY);
Object[] res = world.calcMinDistanceAndObject3D(camera.getPosition(), dir, 10000);
Object3D clickedObject = (Object3D)res[1];
while (clickedObject != null && clickedObject.getName().startsWith("transparent")) {
dir.z = clickedObject.getTransformedCenter().z;
res = world.calcMinDistanceAndObject3D(camera.getPosition(), dir, 10000);
clickedObject = (Object3D)res[1];
}
Is there a way for doing it?