Beispiel #1
0
  /**
   * Edit the input {@link Geometry} with the given edit operation. Clients can create subclasses of
   * {@link GeometryEditorOperation} or {@link CoordinateOperation} to perform required
   * modifications.
   *
   * @param geometry the Geometry to edit
   * @param operation the edit operation to carry out
   * @return a new {@link Geometry} which is the result of the editing (which may be empty)
   */
  public Geometry edit(Geometry geometry, GeometryEditorOperation operation) {
    // nothing to do
    if (geometry == null) return null;

    Geometry result = editInternal(geometry, operation);
    if (isUserDataCopied) {
      result.setUserData(geometry.getUserData());
    }
    return result;
  }
  private Mesh[] findTargets(Node node) {
    Mesh sharedMesh = null;
    ArrayList<Mesh> animatedMeshes = new ArrayList<Mesh>();

    for (Spatial child : node.getChildren()) {
      if (!(child instanceof Geometry)) {
        continue; // could be an attachment node, ignore.
      }

      Geometry geom = (Geometry) child;

      // is this geometry using a shared mesh?
      Mesh childSharedMesh = geom.getUserData(UserData.JME_SHAREDMESH);

      if (childSharedMesh != null) {
        // Don't bother with non-animated shared meshes
        if (isMeshAnimated(childSharedMesh)) {
          // child is using shared mesh,
          // so animate the shared mesh but ignore child
          if (sharedMesh == null) {
            sharedMesh = childSharedMesh;
          } else if (sharedMesh != childSharedMesh) {
            throw new IllegalStateException("Two conflicting shared meshes for " + node);
          }
        }
      } else {
        Mesh mesh = geom.getMesh();
        if (isMeshAnimated(mesh)) {
          animatedMeshes.add(mesh);
        }
      }
    }

    if (sharedMesh != null) {
      animatedMeshes.add(sharedMesh);
    }

    return animatedMeshes.toArray(new Mesh[animatedMeshes.size()]);
  }