Another MousePick question


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) { = camera;
        this.scene = scene;
   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();

            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 += ", ";
            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:

How are you getting those trees?  Are they dynamically generated?

Looks very nice!


Let's get the obvious issues out of the way first:

  1. Your action is getting called, correct? i.e. you see : "itms: 0" printed out.
  2. Your trees are set to Collidable = true? This is the default, so they should be…
  3. does TestPick work for you? Not at work yet, so just want to make sure picking is working in general.


THX!!! The trees are made by my self using blender. The contains two meshes (trunk/branches) and is randomly rotated over the terrain. Email me, and i send it to you. If you like it, use there tree in your demos :wink:


I try a little bit, and found, that my Ray does not represent the korrekt direktion. My ray use the direktion of the camera combined with the position of my mouse. I found a solution for me that works fine. THX.

Look the tech-demo at:

(use num-block for navigation/rotation or mouse for moving)

Can you post how you do it now? At the moment my direction look like it is using random numbers instead the mouse.