Example #1
0
  public static void findTrianglePick(
      final Mesh mesh, final Ray3 toTest, final List<PrimitiveKey> results) {
    if (mesh.getWorldBound() == null
        || !mesh.getSceneHints().isPickingHintEnabled(PickingHint.Pickable)) {
      return;
    }

    if (mesh.getWorldBound().intersects(toTest)) {
      final CollisionTree ct = CollisionTreeManager.getInstance().getCollisionTree(mesh);
      if (ct != null) {
        ct.getBounds().transform(mesh.getWorldTransform(), ct.getWorldBounds());
        ct.intersect(toTest, results);
      }
    }
  }
Example #2
0
  /**
   * This function checks for intersection between this mesh and the given one. On the first
   * intersection, true is returned.
   *
   * @param toCheck The intersection testing mesh.
   * @return True if they intersect.
   */
  public static boolean hasTriangleCollision(final Mesh testMesh, final Mesh toCheck) {
    if (!testMesh.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)
        || !toCheck.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)) {
      return false;
    }

    final CollisionTree thisCT = CollisionTreeManager.getInstance().getCollisionTree(testMesh);
    final CollisionTree checkCT = CollisionTreeManager.getInstance().getCollisionTree(toCheck);

    if (thisCT == null || checkCT == null) {
      return false;
    }

    final ReadOnlyTransform worldTransform = testMesh.getWorldTransform();
    thisCT.getBounds().transform(worldTransform, thisCT.getWorldBounds());
    return thisCT.intersect(checkCT);
  }
Example #3
0
  /**
   * This function finds all intersections between this mesh and the checking one. The intersections
   * are stored as Integer objects of Triangle indexes in each of the parameters.
   *
   * @param toCheck The Mesh to check.
   * @param testIndex The array of triangle indexes intersecting in this mesh.
   * @param otherIndex The array of triangle indexes intersecting in the given mesh.
   */
  public static void findPrimitiveCollision(
      final Mesh testMesh,
      final Mesh toCheck,
      final List<PrimitiveKey> testIndex,
      final List<PrimitiveKey> otherIndex) {
    if (!testMesh.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)
        || !toCheck.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)) {
      return;
    }

    final CollisionTree myTree = CollisionTreeManager.getInstance().getCollisionTree(testMesh);
    final CollisionTree otherTree = CollisionTreeManager.getInstance().getCollisionTree(toCheck);

    if (myTree == null || otherTree == null) {
      return;
    }

    myTree.getBounds().transform(testMesh.getWorldTransform(), myTree.getWorldBounds());

    myTree.intersect(otherTree, testIndex, otherIndex);
  }