ihmcrobotics / ihmc-javafx-toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Method for Pick Ray

georgwi opened this issue · comments

It would be nice to move this method to the JavaFXTools:

   private static Line3D getPickRay(Camera camera, MouseEvent event)
   {
      Point3D point1 = new Point3D();
      point1.setX(camera.getLocalToSceneTransform().getTx());
      point1.setY(camera.getLocalToSceneTransform().getTy());
      point1.setZ(camera.getLocalToSceneTransform().getTz());

      Point3D point2 = new Point3D();
      javafx.geometry.Point3D pointOnProjectionPlane = CameraHelper.pickProjectPlane(camera, event.getSceneX(), event.getSceneY());
      point2.setX(pointOnProjectionPlane.getX());
      point2.setY(pointOnProjectionPlane.getY());
      point2.setZ(pointOnProjectionPlane.getZ());
      
      return new Line3D(point1, point2);
   }

Which returns the line through the camera and the mouse pointer to be used to figure out what the user is pointing at.