PickResults Error

Hi community,



i have a little problem with the PickResult Class:



my SceneRootNode myRoot contains some Quads. Know i want to check, if the mouse cursor is pointing to such a quad. Therefore is used the PickResult Class as follows:


public class CPTooltip {
   
   private PickResults pr;
   private Node myRoot;
   private DisplaySystem display;
   
   public CPTooltip(Node myRoot, DisplaySystem display) {
      this.myRoot = myRoot;
      this.display = display;
   }
   
   
   public void findMesh() {
      Vector2f screenPos = new Vector2f();
      screenPos.set(MouseInput.get().getXAbsolute(), MouseInput.get().getYAbsolute());
      Vector3f worldCoords = display.getWorldCoordinates(screenPos, 0);
      Vector3f worldCoords2 = display.getWorldCoordinates(screenPos, 1);
      Ray ray = new Ray(worldCoords, worldCoords2.subtractLocal(worldCoords).normalizeLocal());
      pr = new BoundingPickResults();
      pr.clear();
      myRoot.findPick(ray, pr);
      
      for (int i = 0; i < pr.getNumber(); i++) {
         System.out.println("Results: " + "n");
         String s = pr.getPickData(i).getTargetMesh().getName();
         System.out.println(s + "n");
      }
   }
}



my Quads are defined this way:

boxes = new Box[4];
      boxNode = new Node("Box Node");
      center1 = new Vector3f(display.getWorldCoordinates(new Vector2f(220, 50), 1));
      center2 = new Vector3f(display.getWorldCoordinates(new Vector2f(320, 170), 1));
      center3 = new Vector3f(display.getWorldCoordinates(new Vector2f(450, 70), 1));
      center4 = new Vector3f(display.getWorldCoordinates(new Vector2f(550, 270), 1));
      box1 = new Box("Box 1", center1, x, 230, z);
      box2 = new Box("Box 2", center2, x, 150, z);
      box3 = new Box("Box 3", center3, x, 70, z);
      box4 = new Box("Box 4", center4, x, 70, z);
      box1.setDefaultColor(ColorRGBA.cyan);
      box2.setDefaultColor(ColorRGBA.orange);
      box3.setDefaultColor(ColorRGBA.pink);
      box4.setDefaultColor(ColorRGBA.yellow);
      box1.setModelBound(new BoundingBox());
      box2.setModelBound(new BoundingBox());
      box3.setModelBound(new BoundingBox());
      box4.setModelBound(new BoundingBox());
      box1.updateModelBound();
      box2.updateModelBound();
      box3.updateModelBound();
      box4.updateModelBound();
      boxes[0] = box1;
      boxes[1] = box2;
      boxes[2] = box3;
      boxes[3] = box4;
      boxNode.attachChild(box1);
      boxNode.attachChild(box2);
      boxNode.attachChild(box3);
      boxNode.attachChild(box4);



but unfortunately, the code doesn't work proper. it never finds a matching position. does anybody know where my error is? thx!!!

no one got an idea?

maybe someone can explain me the difference between PickResults PickData und BoundingPickresults?



the javadoc is nearly nothing described. that would be very kind. then i can find my error by myself i hope

Try to set a model bound to the root node or some other node.



rootNode.setModelBound(new BoundingBox());

rootNode.updateModelBound();