Examples of TriangleMesh


Examples of artofillusion.object.TriangleMesh

    }
  }
 
  public void simplifyCommand()
  {
    TriangleMesh theMesh = (TriangleMesh) objInfo.getObject();
    boolean selection[] = selected;
    ValueField errorField = new ValueField(0.01, ValueField.NONNEGATIVE);
    int i;

    ComponentsDialog dlg = new ComponentsDialog(this, Translate.text("simplifyMeshTitle"),
            new Widget[] {errorField}, new String[] {Translate.text("maxSurfaceError")});
    if (!dlg.clickedOk())
      return;
    setUndoRecord(new UndoRecord(this, false, UndoRecord.COPY_OBJECT, new Object [] {theMesh, theMesh.duplicate()}));

    // If we are not in Edge selection mode, convert the selection to edges.

    if (selectMode == POINT_MODE)
    {
      Edge e[] = theMesh.getEdges();
      boolean newSel[] = new boolean [e.length];
      for (i = 0; i < e.length; i++)
        newSel[i] = (selection[e[i].v1] && selection[e[i].v2]);
      selection = newSel;
    }
    if (selectMode == FACE_MODE)
    {
      Edge e[] = theMesh.getEdges();
      boolean newSel[] = new boolean [e.length];
      for (i = 0; i < e.length; i++)
        newSel[i] = (selection[e[i].f1] || (e[i].f2 > -1 && selection[e[i].f2]));
      selection = newSel;
    }
View Full Code Here

Examples of artofillusion.object.TriangleMesh

  {
    BStandardDialog dlg = new BStandardDialog("", UIUtilities.breakString(Translate.text("optimizeMeshTitle")), BStandardDialog.QUESTION);
    String options[] = new String [] {Translate.text("button.ok"), Translate.text("button.cancel")};
    if (dlg.showOptionDialog(this, options, options[0]) == 1)
      return;
    TriangleMesh theMesh = (TriangleMesh) objInfo.getObject();
    setUndoRecord(new UndoRecord(this, false, UndoRecord.COPY_OBJECT, new Object [] {theMesh, theMesh.duplicate()}));
    theMesh.copyObject(TriangleMesh.optimizeMesh(theMesh));
    setMesh(theMesh);
    for (int i = 0; i < selected.length; i++)
      selected[i] = false;
    setSelection(selected);
    updateImage();
View Full Code Here

Examples of artofillusion.object.TriangleMesh

    updateImage();
  }

  public void bevelCommand()
  {
    final TriangleMesh theMesh = (TriangleMesh) objInfo.getObject();
    final ValueField heightField = new ValueField(0.0, ValueField.NONE), widthField = new ValueField(0.0, ValueField.NONE);
    final ObjectPreviewCanvas preview = new ObjectPreviewCanvas(new ObjectInfo(theMesh, new CoordinateSystem(), ""));
    final int bevelMode[];
    if (selectMode == FACE_MODE)
      bevelMode = new int [] {TriMeshBeveler.BEVEL_FACE_GROUPS, TriMeshBeveler.BEVEL_FACES};
    else if (selectMode == POINT_MODE)
      bevelMode = new int [] {TriMeshBeveler.BEVEL_VERTICES, TriMeshBeveler.BEVEL_VERTICES};
    else
      bevelMode = new int [] {TriMeshBeveler.BEVEL_EDGES, TriMeshBeveler.BEVEL_EDGES};
    final BComboBox applyChoice = new BComboBox(new String [] {
      Translate.text("selectionAsWhole"),
      Translate.text("individualFaces")
    });
    applyChoice.addEventLink(ValueChangedEvent.class, new Object() {
      void processEvent()
      {
        TriMeshBeveler beveler = new TriMeshBeveler(theMesh, selected, bevelMode[applyChoice.getSelectedIndex()]);
        double height = heightField.getValue();
        double width = widthField.getValue();
        preview.setObject(beveler.bevelMesh(height, width));
        preview.repaint();
      }
    });
    Object listener = new Object() {
      void processEvent()
      {
        TriMeshBeveler beveler = new TriMeshBeveler(theMesh, selected, bevelMode[applyChoice.getSelectedIndex()]);
        double height = heightField.getValue();
        double width = widthField.getValue();
        preview.setObject(beveler.bevelMesh(height, width));
        preview.repaint();
      }
    };
    heightField.addEventLink(ValueChangedEvent.class, listener);
    widthField.addEventLink(ValueChangedEvent.class, listener);
    preview.setPreferredSize(new Dimension(200, 200));
    ComponentsDialog dlg;
    if (selectMode == FACE_MODE)
      dlg = new ComponentsDialog(this, Translate.text("bevelFacesTitle"),
          new Widget[] {heightField, widthField, applyChoice, preview},
          new String [] {Translate.text("extrudeHeight"), Translate.text("bevelWidth"), Translate.text("applyTo"), ""});
    else if (selectMode == POINT_MODE)
      dlg = new ComponentsDialog(this, Translate.text("bevelPointsTitle"),
          new Widget[] {heightField, widthField, preview},
          new String [] {Translate.text("extrudeHeight"), Translate.text("bevelWidth"), ""});
    else
      dlg = new ComponentsDialog(this, Translate.text("bevelEdgesTitle"),
          new Widget[] {heightField, widthField, preview},
          new String [] {Translate.text("extrudeHeight"), Translate.text("bevelWidth"), ""});
    if (!dlg.clickedOk())
      return;
    double height = heightField.getValue();
    double width = widthField.getValue();
    setUndoRecord(new UndoRecord(this, false, UndoRecord.COPY_OBJECT, new Object [] {theMesh, theMesh.duplicate()}));

    // Generate the new mesh.
   
    TriMeshBeveler beveler = new TriMeshBeveler(theMesh, selected, bevelMode[applyChoice.getSelectedIndex()]);
    theMesh.copyObject(beveler.bevelMesh(height, width));
    setMesh(theMesh);
    setSelection(beveler.getNewSelection());
  }
View Full Code Here

Examples of artofillusion.object.TriangleMesh

 
  private boolean isBoundaryClosed(int edges[])
  {
    if (edges.length < 3)
      return false;
    TriangleMesh theMesh = (TriangleMesh) objInfo.getObject();
    Edge ed[] = theMesh.getEdges();
    Edge first = ed[edges[0]];
    Edge last = ed[edges[edges.length-1]];
    return (first.v1 == last.v1 || first.v1 == last.v2 || first.v2 == last.v1 || first.v2 == last.v2);
  }
View Full Code Here

Examples of artofillusion.object.TriangleMesh

    return index;
  }
 
  public void closeBoundaryCommand()
  {
    TriangleMesh theMesh = (TriangleMesh) objInfo.getObject();
    Vertex vt[] = (Vertex []) theMesh.getVertices();
    Edge ed[] = theMesh.getEdges();
    Face fc[] = theMesh.getFaces();
    int boundaryList[][] = findSelectedBoundaries()
    Vec3 newvert[] = new Vec3 [vt.length+boundaryList.length];
    int newface[][], count = 0;
   
    // First, add all of the current vertices and faces to the lists.
   
    for (int i = 0; i < vt.length; i++)
      newvert[i] = vt[i].r;
    for (int i = 0; i < boundaryList.length; i++)
      count += boundaryList[i].length;
    newface = new int [fc.length+count][];
    for (int i = 0; i < fc.length; i++)
      newface[i] = new int [] {fc[i].v1, fc[i].v2, fc[i].v3};

    // For each boundary, add new faces to close it.

    int faceIndex = fc.length;
    int vertIndex = vt.length;
    for (int i = 0; i < boundaryList.length; i++)
    {
      if (boundaryList[i].length < 2)
        continue;
      Edge ed0 = ed[boundaryList[i][0]];
      Edge ed1 = ed[boundaryList[i][1]];
      boolean closed = isBoundaryClosed(boundaryList[i]);
      if (boundaryList[i].length == 2 || (boundaryList[i].length == 3 && closed))
      {
        // Add a single new face spanning the two edges.

        Face f = fc[ed0.f1];
        int thirdVert = (ed0.v1 == ed1.v1 || ed0.v2 == ed1.v1 ? ed1.v2 : ed1.v1);
        if ((f.v1 == ed0.v1 && f.v2 == ed0.v2) || (f.v2 == ed0.v1 && f.v3 == ed0.v2) || (f.v3 == ed0.v1 && f.v1 == ed0.v2))
          newface[faceIndex++] = new int [] {ed0.v2, ed0.v1, thirdVert};
        else
          newface[faceIndex++] = new int [] {ed0.v1, ed0.v2, thirdVert};
      }
      else
      {
        // Add a single vertex in the center, and faces surrounding it.

        Vec3 center = new Vec3();
        int j = (ed0.v1 == ed1.v1 || ed0.v1 == ed1.v2 ? ed0.v2 : ed0.v1);
        for (int k = 0; k < boundaryList[i].length; k++)
        {
          center.add(vt[j].r);
          Edge e = ed[boundaryList[i][k]];
          j = (e.v1 == j ? e.v2 : e.v1);
        }
        if (closed)
          center.scale(1.0/boundaryList[i].length);
        else
        {
          center.add(vt[j].r);
          center.scale(1.0/(boundaryList[i].length+1));
        }
        newvert[vertIndex] = center;
        for (int k = 0; k < boundaryList[i].length; k++)
        {
          Edge e = ed[boundaryList[i][k]];
          Face f = fc[e.f1];
          if ((f.v1 == e.v1 && f.v2 == e.v2) || (f.v2 == e.v1 && f.v3 == e.v2) || (f.v3 == e.v1 && f.v1 == e.v2))
            newface[faceIndex++] = new int [] {e.v2, e.v1, vertIndex};
          else
            newface[faceIndex++] = new int [] {e.v1, e.v2, vertIndex};
        }
        vertIndex++;
      }
    }

    // Remove empty elements from the end of the arrays.

    if (faceIndex < newface.length)
    {
      int newface2[][] = new int[faceIndex][];
      System.arraycopy(newface, 0, newface2, 0, faceIndex);
      newface = newface2;
    }
    if (vertIndex < newvert.length)
    {
      Vec3 newvert2[] = new Vec3[vertIndex];
      System.arraycopy(newvert, 0, newvert2, 0, vertIndex);
      newvert = newvert2;
    }
   
    // Create the new mesh.
   
    TriangleMesh newmesh = new TriangleMesh(newvert, newface);
    Vertex newvt[] = (Vertex []) newmesh.getVertices();
    Edge newed[] = newmesh.getEdges();
    newmesh.copyTextureAndMaterial(theMesh);
    newmesh.setSmoothingMethod(theMesh.getSmoothingMethod());

    // Update the texture parameters.
   
    TextureParameter param[] = theMesh.getParameters();
    ParameterValue oldParamVal[] = theMesh.getParameterValues();
    ParameterValue newParamVal[] = new ParameterValue [oldParamVal.length];
    for (int i = 0; i < oldParamVal.length; i++)
    {
      if (oldParamVal[i] instanceof VertexParameterValue)
      {
        double oldval[] = ((VertexParameterValue) oldParamVal[i]).getValue();
        double newval[] = new double [newvert.length];
        for (int j = 0; j < oldval.length; j++)
          newval[j] = oldval[j];
        for (int j = oldval.length; j < newval.length; j++)
          newval[j] = param[i].defaultVal;
        newParamVal[i] = new VertexParameterValue(newval);
      }
      else if (oldParamVal[i] instanceof FaceParameterValue)
      {
        double oldval[] = ((FaceParameterValue) oldParamVal[i]).getValue();
        double newval[] = new double [newface.length];
        for (int j = 0; j < oldval.length; j++)
          newval[j] = oldval[j];
        for (int j = oldval.length; j < newval.length; j++)
          newval[j] = param[i].defaultVal;
        newParamVal[i] = new FaceParameterValue(newval);
      }
      else if (oldParamVal[i] instanceof FaceVertexParameterValue)
      {
        FaceVertexParameterValue fvpv = (FaceVertexParameterValue) oldParamVal[i];
        double newval[][] = new double [newface.length][3];
        for (int j = 0; j < 3; j++)
        {
          for (int k = 0; k < fvpv.getFaceCount(); k++)
            newval[k][j] = fvpv.getValue(k, j);
          for (int k = fvpv.getFaceCount(); k < newface.length; k++)
            newval[k][j] = param[i].defaultVal;
        }
        newParamVal[i] = new FaceVertexParameterValue(newval);
      }
      else
        newParamVal[i] = oldParamVal[i].duplicate();
    }
    newmesh.setParameterValues(newParamVal);
   
    // Copy over the smoothness values.
   
    for (int i = 0; i < vt.length; i++)
      newvt[i].smoothness = vt[i].smoothness;
View Full Code Here

Examples of artofillusion.object.TriangleMesh

  {
    final int boundaryList[][] = findSelectedBoundaries()
    if (boundaryList.length != 2)
      return;
    final int boundaryVert[][] = new int [2][];
    TriangleMesh theMesh = (TriangleMesh) objInfo.getObject();
    Vertex vt[] = (Vertex []) theMesh.getVertices();
    Edge ed[] = theMesh.getEdges();
    boolean closed = isBoundaryClosed(boundaryList[0]);
    if (closed != isBoundaryClosed(boundaryList[1]))
    {
      new BStandardDialog("", Translate.text("cannotJoinOpenAndClosed"), BStandardDialog.ERROR).showMessageDialog(this);
      return;
View Full Code Here

Examples of artofillusion.object.TriangleMesh

  TriangleMesh doJoinBoundaries(int boundary[][], int boundaryVert[][], double offset, boolean reverse)
  {
    int maxsteps = (boundary[0].length > boundary[1].length ? boundary[0].length : boundary[1].length);
    double step0 = boundary[0].length/((double) maxsteps);
    double step1 = (reverse ? -1.0 : 1.0)*boundary[1].length/((double) maxsteps);
    TriangleMesh theMesh = (TriangleMesh) objInfo.getObject();
    Vertex vt[] = (Vertex []) theMesh.getVertices();
    Edge ed[] = theMesh.getEdges();
    Face fc[] = theMesh.getFaces();
    Vec3 newvert[] = new Vec3 [vt.length];
    int newface[][] = new int [fc.length+boundary[0].length+boundary[1].length][];

    // First copy over the old vertices and faces.
   
    for (int i = 0; i < vt.length; i++)
      newvert[i] = vt[i].r;
    for (int i = 0; i < fc.length; i++)
      newface[i] = new int [] {fc[i].v1, fc[i].v2, fc[i].v3};
    int count = fc.length;
   
    // Go around the boundaries and add new faces.
   
    if (isBoundaryClosed(boundary[0]))
    {
      // We are connecting two closed boundaries.
     
      double p0 = 0.0, p1 = offset;
      int i0prev = 0, i1prev = ((int) Math.round(p1)+boundary[1].length) % boundary[1].length;
      for (int i = 1; i <= maxsteps; i++)
      {
        p0 += step0;
        p1 += step1;
        while (p1 < 0.0)
          p1 += boundary[1].length;
        int i0 = ((int) Math.round(p0)) % boundary[0].length;
        int i1 = ((int) Math.round(p1)) % boundary[1].length;
        if (i0 != i0prev)
        {
          Edge e = ed[boundary[0][step0 > 0.0 ? i0prev : i0]];
          Face f = fc[e.f1];
          int v1 = boundaryVert[0][i0prev], v2 = boundaryVert[0][i0];
          if ((f.v1 == v1 && f.v2 == v2) || (f.v2 == v1 && f.v3 == v2) || (f.v3 == v1 && f.v1 == v2))
            newface[count++] = new int [] {v2, v1, boundaryVert[1][i1prev]};
          else
            newface[count++] = new int [] {v1, v2, boundaryVert[1][i1prev]};
        }
        if (i1 != i1prev)
        {
          Edge e = ed[boundary[1][step1 > 0.0 ? i1prev : i1]];
          Face f = fc[e.f1];
          int v1 = boundaryVert[1][i1prev], v2 = boundaryVert[1][i1];
          if ((f.v1 == v1 && f.v2 == v2) || (f.v2 == v1 && f.v3 == v2) || (f.v3 == v1 && f.v1 == v2))
            newface[count++] = new int [] {v2, v1, boundaryVert[0][i0]};
          else
            newface[count++] = new int [] {v1, v2, boundaryVert[0][i0]};
        }
        i0prev = i0;
        i1prev = i1;
      }
    }
    else
    {
      // We are connecting two open boundaries.
     
      double p0 = 0.0, p1 = (reverse ? boundary[1].length : 0.0);
      int i0prev = 0, i1prev = (int) Math.round(p1);
      while (count < newface.length)
      {
        p0 += step0;
        p1 += step1;
        int i0 = (int) Math.round(p0);
        int i1 = (int) Math.round(p1);
        if (i0 < 0)
          i0 = 0;
        if (i1 < 0)
          i1 = 0;
        if (i0 > boundary[0].length)
          i0 = boundary[0].length;
        if (i1 > boundary[1].length)
          i1 = boundary[1].length;
        if (i0 != i0prev)
        {
          Edge e = ed[boundary[0][i0prev < i0 ? i0prev : i0]];
          Face f = fc[e.f1];
          int v1 = boundaryVert[0][i0prev], v2 = boundaryVert[0][i0];
          if ((f.v1 == v1 && f.v2 == v2) || (f.v2 == v1 && f.v3 == v2) || (f.v3 == v1 && f.v1 == v2))
            newface[count++] = new int [] {v2, v1, boundaryVert[1][i1prev]};
          else
            newface[count++] = new int [] {v1, v2, boundaryVert[1][i1prev]};
        }
        if (i1 != i1prev)
        {
          Edge e = ed[boundary[1][i1prev < i1 ? i1prev : i1]];
          Face f = fc[e.f1];
          int v1 = boundaryVert[1][i1prev], v2 = boundaryVert[1][i1];
          if ((f.v1 == v1 && f.v2 == v2) || (f.v2 == v1 && f.v3 == v2) || (f.v3 == v1 && f.v1 == v2))
            newface[count++] = new int [] {v2, v1, boundaryVert[0][i0]};
          else
            newface[count++] = new int [] {v1, v2, boundaryVert[0][i0]};
        }
        i0prev = i0;
        i1prev = i1;
      }
    }
   
    // Create the new mesh.
   
    TriangleMesh newmesh = new TriangleMesh(newvert, newface);
    Vertex newvt[] = (Vertex []) newmesh.getVertices();
    Edge newed[] = newmesh.getEdges();
    newmesh.copyTextureAndMaterial(theMesh);
    newmesh.setSmoothingMethod(theMesh.getSmoothingMethod());

    // Update the texture parameters.
   
    TextureParameter param[] = theMesh.getParameters();
    ParameterValue oldParamVal[] = theMesh.getParameterValues();
    ParameterValue newParamVal[] = new ParameterValue [oldParamVal.length];
    for (int i = 0; i < oldParamVal.length; i++)
    {
      if (oldParamVal[i] instanceof FaceParameterValue)
      {
        double oldval[] = ((FaceParameterValue) oldParamVal[i]).getValue();
        double newval[] = new double [newface.length];
        for (int j = 0; j < oldval.length; j++)
          newval[j] = oldval[j];
        if (param[i] == getFaceIndexParameter()) // The parameter added by the editor window to record face indices
          for (int j = oldval.length; j < newval.length; j++)
            newval[j] = j;
        else
          for (int j = oldval.length; j < newval.length; j++)
            newval[j] = param[i].defaultVal;
        newParamVal[i] = new FaceParameterValue(newval);
      }
      else if (oldParamVal[i] instanceof FaceVertexParameterValue)
      {
        FaceVertexParameterValue fvpv = (FaceVertexParameterValue) oldParamVal[i];
        double newval[][] = new double [newface.length][3];
        for (int j = 0; j < 3; j++)
        {
          for (int k = 0; k < fvpv.getFaceCount(); k++)
            newval[k][j] = fvpv.getValue(k, j);
          for (int k = fvpv.getFaceCount(); k < newface.length; k++)
            newval[k][j] = param[i].defaultVal;
        }
        newParamVal[i] = new FaceVertexParameterValue(newval);
      }
      else
        newParamVal[i] = oldParamVal[i].duplicate();
    }
    newmesh.setParameterValues(newParamVal);
   
    // Copy over the smoothness values.
   
    for (int i = 0; i < vt.length; i++)
      newvt[i].smoothness = vt[i].smoothness;
View Full Code Here

Examples of artofillusion.object.TriangleMesh

    return newmesh;
  }

  public void extractFacesCommand()
  {
    TriangleMesh theMesh = (TriangleMesh) objInfo.getObject();
    Vertex vt[] = (Vertex []) theMesh.getVertices();
    Face fc[] = theMesh.getFaces();
    Vector<Integer> faces = new Vector<Integer>();
    TreeSet<Integer> vertices = new TreeSet<Integer>();

    if (selectMode != FACE_MODE)
      return;
   
    // Find the selected faces and make a new mesh out of them.
   
    for (int i = 0; i < selected.length; i++)
      if (selected[i])
        faces.addElement(i);
    if (faces.size() == 0)
      return;
    for (Integer face : faces)
    {
      vertices.add(fc[face].v1);
      vertices.add(fc[face].v2);
      vertices.add(fc[face].v3);
    }
    int vertIndex[] = new int[vt.length];
    Arrays.fill(vertIndex, -1);
    Vec3 v[] = new Vec3[vertices.size()];
    int count = 0;
    for (Integer vertex : vertices)
    {
      v[count] = new Vec3(vt[vertex].r);
      vertIndex[vertex] = count++;
    }
    int f[][] = new int[faces.size()][];
    count = 0;
    for (Integer face : faces)
      f[count++] = new int[] {vertIndex[fc[face].v1], vertIndex[fc[face].v2], vertIndex[fc[face].v3]};
    TriangleMesh mesh = new TriangleMesh(v, f);
    mesh.copyTextureAndMaterial(theMesh);
    mesh.setSmoothingMethod(theMesh.getSmoothingMethod());

    // Verify that it is a valid mesh.

    int vertexEdgeCount[] = new int[vertices.size()];
    for (int i = 0; i < mesh.getEdges().length; i++)
    {
      Edge edge = mesh.getEdges()[i];
      if (edge.f2 == -1)
      {
        vertexEdgeCount[edge.v1]++;
        vertexEdgeCount[edge.v2]++;
      }
    }
    for (int i = 0; i < vertexEdgeCount.length; i++)
    {
      if (vertexEdgeCount[i] != 0 && vertexEdgeCount[i] != 2)
      {
        new BStandardDialog("", Translate.text("illegalExtract"), BStandardDialog.ERROR).showMessageDialog(this);
        return;
      }
    }

    // Copy over smoothness values.

    for (Integer vertex : vertices)
        ((TriangleMesh.Vertex) mesh.getVertices()[vertIndex[vertex]]).smoothness = vt[vertex].smoothness;
    for (int i = 0; i < faces.size(); i++)
    {
      Face face = fc[faces.get(i)];
      Face newFace = mesh.getFaces()[i];
      mesh.getEdges()[newFace.e1].smoothness = theMesh.getEdges()[face.e1].smoothness;
      mesh.getEdges()[newFace.e2].smoothness = theMesh.getEdges()[face.e2].smoothness;
      mesh.getEdges()[newFace.e3].smoothness = theMesh.getEdges()[face.e3].smoothness;
    }

    // Copy over parameter values.

    ParameterValue oldValues[] = theMesh.getParameterValues();
    ParameterValue newValues[] = mesh.getParameterValues();
    for (int i = 0; i < oldValues.length; i++)
    {
      if (oldValues[i] instanceof FaceParameterValue)
      {
        FaceParameterValue old = (FaceParameterValue) oldValues[i];
View Full Code Here

Examples of artofillusion.object.TriangleMesh

    }
  }

  public void extractCurveCommand()
  {
    TriangleMesh theMesh = (TriangleMesh) objInfo.getObject();
    Vertex vt[] = (Vertex []) theMesh.getVertices();
    Edge ed[] = theMesh.getEdges();
    Vector<Edge> edges = new Vector<Edge>();
    int i;

    if (selectMode != EDGE_MODE)
      return;

    // Find the select edges, and try to chain them together.

    for (i = 0; i < selected.length; i++)
      if (selected[i])
        edges.addElement(ed[i]);
    if (edges.size() == 0)
      return;
    Edge first = edges.elementAt(0), last = first;
    Vector<Edge> ordered = new Vector<Edge>();
    ordered.addElement(first);
    edges.removeElementAt(0);
    while (edges.size() > 0)
    {
      for (i = 0; i < edges.size(); i++)
      {
        Edge e = edges.elementAt(i);
        if (e.v1 == first.v1 || e.v2 == first.v1 || e.v1 == first.v2 || e.v2 == first.v2)
        {
          ordered.insertElementAt(e, 0);
          first = e;
          break;
        }
        if (e.v1 == last.v1 || e.v2 == last.v1 || e.v1 == last.v2 || e.v2 == last.v2)
        {
          ordered.addElement(e);
          last = e;
          break;
        }
      }
      if (i == edges.size())
      {
        new BStandardDialog("", Translate.text("edgesNotContinuous"), BStandardDialog.ERROR).showMessageDialog(this);
        return;
      }
      edges.removeElementAt(i);
    }

    // Now find the sequence of vertices.

    boolean closed = (ordered.size() > 2 && (last.v1 == first.v1 || last.v2 == first.v1 || last.v1 == first.v2 || last.v2 == first.v2));
    Vec3 v[] = new Vec3 [closed ? ordered.size() : ordered.size()+1];
    float smoothness[] = new float [v.length];
    Edge second = (ordered.size() == 1 ? first : ordered.elementAt(1));
    int prev;
    if (first.v1 == second.v1 || first.v1 == second.v2)
      prev = first.v2;
    else
      prev = first.v1;
    for (i = 0; i < ordered.size(); i++)
    {
      Edge e = ordered.elementAt(i);
      v[i] = new Vec3(vt[prev].r);
      smoothness[i] = vt[prev].smoothness;
      prev = (e.v1 == prev ? e.v2 : e.v1);
    }
    if (!closed)
    {
      v[i] = new Vec3(vt[prev].r);
      smoothness[i] = vt[prev].smoothness;
    }
    int smoothingMethod = theMesh.getSmoothingMethod();
    if (smoothingMethod == Mesh.SMOOTH_SHADING)
      smoothingMethod = Mesh.NO_SMOOTHING;
    Curve cv = new Curve(v, smoothness, smoothingMethod, closed);
    Widget parent = (Widget) parentWindow;
    while (parent != null && !(parent instanceof LayoutWindow))
View Full Code Here

Examples of artofillusion.object.TriangleMesh

    }
  }

  public void setSmoothnessCommand()
  {
    final TriangleMesh theMesh = (TriangleMesh) objInfo.getObject();
    TriangleMesh oldMesh = (TriangleMesh) theMesh.duplicate();
    final Vertex vt[] = (Vertex []) theMesh.getVertices();
    final Edge ed[] = theMesh.getEdges();
    final boolean pointmode = (selectMode == POINT_MODE);
    final ActionProcessor processor = new ActionProcessor();
    float value;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.