Hello,
I have a lot of objects (trees) in my scene. If i want to pick on of them, the picked object is not returned by the event.
public class SelectObject extends MouseInputAction {
private Camera camera;
private Node scene;
private float shotTime = 0;
private int hits = 0;
private int shots = 0;
private String hitItems;
public SelectObject(Camera camera, Node scene) {
this.camera = camera;
this.scene = scene;
}
@Override
public void performAction(InputActionEvent evt) {
shotTime += evt.getTime();
if( MouseInput.get().isButtonDown(0) && shotTime > 0.1f) {
shotTime = 0;
Ray ray = new Ray(camera.getLocation(), camera.getDirection());
PickResults results = new BoundingPickResults();
results.setCheckDistance(false);
scene.calculatePick(ray,results);
hits += results.getNumber();
hitItems = "";
if(results.getNumber() > 0) {
for(int i = 0; i < results.getNumber(); i++) {
hitItems += results.getPickData(i).getTargetMesh().getName();
if(i != results.getNumber() -1) {
hitItems += ", ";
}
}
}
shots++;
results.clear();
Logger.getAnonymousLogger().info("itms: " + hitItems);
}
}
}
I try BoundingPickResults(); and TrianglesPickResults(). Both with the same results. Look at the complex boundings inside my scene in the screenshots.
Any suggestion?
See the screens: