Esempio n. 1
0
  /**
   * This is an external all for direct usage.
   *
   * @param tpf
   */
  public void pick(Vector3f direction) {
    results.clear();
    this.direction = direction;
    ray.setOrigin(originObject.getWorldTranslation());
    ray.setDirection(direction);
    scene.collideWith(ray, results);

    if (results.size() > 0) {
      // The closest collision point is what was truly hit:
      for (int i = 0; i < results.size(); i++) {
        CollisionResult col = results.getCollision(i);

        if (collisionTypes != null && !originObject.hasChild(col.getGeometry())) {
          for (int j = 0; j < collisionTypes.length; j++) {
            String typeStr = collisionTypes[j];
            String type = col.getGeometry().getUserData(TYPE);
            if (type != null && type.equals(typeStr)) {
              contactPoint = col.getContactPoint();
              contactObject = col.getGeometry();
              fireSpatialListener(contactPoint, contactObject, true);
            }
          }
        }
      }
    }
  }
 public int collideWith(Collidable other) {
   TempVars tempVars = TempVars.get();
   try {
     CollisionResults tempResults = tempVars.collisionResults;
     tempResults.clear();
     return collideWith(other, tempResults);
   } finally {
     tempVars.release();
   }
 }