Hi trying to do some object picking, like i readed about on the wiki.
Now it seems to work, until I move the Camera around, then it does not work anymore. It's like when the camera moved then, the positions are not valid anymore. it still uses old positions ? any Ideas ??
//my Call
pickingObject(mouseMapper.getMouseX(), mouseMapper.getMouseY());
// My method
private Object3D pickingObject(int mouseX, int mouseY) {
SimpleVector direction = Interact2D.reproject2D3D(world.getCamera(), buffer, mouseX, mouseY).normalize();
float distance = world.calcMinDistance(world.getCamera().getPosition(), direction, 10000);
int[] res = Interact2D.pickPolygon(world.getVisibilityList(), direction);
if (res != null) {
System.out.println("YAHOO!"); // never happends since I compile the objects
Object3D picked = world.getObject(res[1]);
return picked;
}
if (distance != Object3D.COLLISION_NONE) { // works sometime
Object[] objects = world.calcMinDistanceAndObject3D(world.getCamera().getPosition(), direction, 20000);
Object3D object3D = (Object3D) objects[1];
return (Object3D) objects[1];
}
return null;
}