Ejemplo n.º 1
0
  public Control cloneForSpatial(Spatial spatial) {
    Node clonedNode = (Node) spatial;
    AnimControl ctrl = spatial.getControl(AnimControl.class);
    SkeletonControl clone = new SkeletonControl();
    clone.setSpatial(clonedNode);

    clone.skeleton = ctrl.getSkeleton();
    // Fix animated targets for the cloned node
    clone.targets = findTargets(clonedNode);

    // Fix attachments for the cloned node
    for (int i = 0; i < clonedNode.getQuantity(); i++) {
      // go through attachment nodes, apply them to correct bone
      Spatial child = clonedNode.getChild(i);
      if (child instanceof Node) {
        Node clonedAttachNode = (Node) child;
        Bone originalBone = (Bone) clonedAttachNode.getUserData("AttachedBone");

        if (originalBone != null) {
          Bone clonedBone = clone.skeleton.getBone(originalBone.getName());

          clonedAttachNode.setUserData("AttachedBone", clonedBone);
          clonedBone.setAttachmentsNode(clonedAttachNode);
        }
      }
    }

    return clone;
  }
Ejemplo n.º 2
0
  /** Computes this Spatial's world bounding volume in the most efficient manner possible. */
  void checkDoBoundUpdate() {
    if ((refreshFlags & RF_BOUND) == 0) {
      return;
    }

    checkDoTransformUpdate();

    // Go to children recursively and update their bound
    if (this instanceof Node) {
      Node node = (Node) this;
      int len = node.getQuantity();
      for (int i = 0; i < len; i++) {
        Spatial child = node.getChild(i);
        child.checkDoBoundUpdate();
      }
    }

    // All children's bounds have been updated. Update my own now.
    updateWorldBound();
  }