コード例 #1
0
ファイル: Geoset.java プロジェクト: Retera/JWC3
 public void applyMatricesToVertices(MDL mdlr) {
   int sz = numVerteces();
   for (int i = 0; i < sz; i++) {
     GeosetVertex gv = vertex.get(i);
     gv.clearBoneAttachments();
     Matrix mx = getMatrix(gv.getVertexGroup());
     mx.updateIds(mdlr);
     int szmx = mx.size();
     for (int m = 0; m < szmx; m++) {
       gv.addBoneAttachment((Bone) mdlr.getIdObject(mx.getBoneId(m)));
     }
   }
 }
コード例 #2
0
ファイル: Geoset.java プロジェクト: Retera/JWC3
 public void applyVerticesToMatrices(MDL mdlr) {
   matrix.clear();
   for (int i = 0; i < vertex.size(); i++) {
     Matrix newTemp = new Matrix(vertex.get(i).bones);
     boolean newMatrix = true;
     for (int m = 0; m < matrix.size() && newMatrix; m++) {
       if (newTemp.equals(matrix.get(m))) {
         newTemp = matrix.get(m);
         newMatrix = false;
       }
     }
     if (newMatrix) {
       matrix.add(newTemp);
       newTemp.updateIds(mdlr);
     }
     vertex.get(i).VertexGroup = matrix.indexOf(newTemp);
     vertex.get(i).setMatrix(newTemp);
   }
 }
コード例 #3
0
ファイル: Geoset.java プロジェクト: Retera/JWC3
  public void doSavePrep(MDL mdlr) {
    purifyFaces();

    // Normals cleared here, in case that becomes a problem later.
    normals.clear();
    // UV Layers cleared here
    uvlayers.clear();
    int bigNum = 0;
    int littleNum = -1;
    for (int i = 0; i < vertex.size(); i++) {
      int temp = vertex.get(i).tverts.size();
      if (temp > bigNum) {
        bigNum = temp;
      }
      if (littleNum == -1 || temp < littleNum) {
        littleNum = temp;
      }
    }
    if (littleNum != bigNum) {
      JOptionPane.showMessageDialog(
          null,
          "Error: Attempting to save a Geoset with Verteces that have differing numbers of TVertices! Empty TVertices will be autogenerated.");
    }
    for (int i = 0; i < bigNum; i++) {
      uvlayers.add(new UVLayer());
    }
    for (int i = 0; i < vertex.size(); i++) {
      normals.add(vertex.get(i).getNormal());
      for (int uv = 0; uv < bigNum; uv++) {
        TVertex temp = vertex.get(i).getTVertex(uv);
        if (temp != null) {
          uvlayers.get(uv).addTVertex(temp);
        } else {
          uvlayers.get(uv).addTVertex(new TVertex(0, 0));
        }
      }
    }
    // Clearing matrix list
    matrix.clear();
    for (int i = 0; i < vertex.size(); i++) {
      Matrix newTemp = new Matrix(vertex.get(i).bones);
      boolean newMatrix = true;
      for (int m = 0; m < matrix.size() && newMatrix; m++) {
        if (newTemp.equals(matrix.get(m))) {
          newTemp = matrix.get(m);
          newMatrix = false;
        }
      }
      if (newMatrix) {
        matrix.add(newTemp);
        newTemp.updateIds(mdlr);
      }
      vertex.get(i).VertexGroup = matrix.indexOf(newTemp);
      vertex.get(i).setMatrix(newTemp);
    }
    for (int i = 0; i < triangle.size(); i++) {
      triangle.get(i).updateVertexIds(this);
    }
    int boneRefCount = 0;
    for (int i = 0; i < matrix.size(); i++) {
      boneRefCount += matrix.get(i).bones.size();
    }
    for (int i = 0; i < matrix.size(); i++) {
      matrix.get(i).updateIds(mdlr);
    }
  }
コード例 #4
0
ファイル: Geoset.java プロジェクト: Retera/JWC3
  public void printTo(PrintWriter writer, MDL mdlr, boolean trianglesTogether) {
    purifyFaces();
    writer.println("Geoset {");
    writer.println("\tVertices " + vertex.size() + " {");

    String tabs = "\t\t";
    // Normals cleared here, in case that becomes a problem later.
    normals.clear();
    // UV Layers cleared here
    uvlayers.clear();
    int bigNum = 0;
    int littleNum = -1;
    for (int i = 0; i < vertex.size(); i++) {
      int temp = vertex.get(i).tverts.size();
      if (temp > bigNum) {
        bigNum = temp;
      }
      if (littleNum == -1 || temp < littleNum) {
        littleNum = temp;
      }
    }
    if (littleNum != bigNum) {
      JOptionPane.showMessageDialog(
          null,
          "Error: Attempting to save a Geoset with Verteces that have differing numbers of TVertices! Empty TVertices will be autogenerated.");
    }
    for (int i = 0; i < bigNum; i++) {
      uvlayers.add(new UVLayer());
    }
    for (int i = 0; i < vertex.size(); i++) {
      writer.println(tabs + vertex.get(i).toString() + ",");
      normals.add(vertex.get(i).getNormal());
      for (int uv = 0; uv < bigNum; uv++) {
        try {
          TVertex temp = vertex.get(i).getTVertex(uv);
          if (temp != null) {
            uvlayers.get(uv).addTVertex(temp);
          } else {
            uvlayers.get(uv).addTVertex(new TVertex(0, 0));
          }
        } catch (IndexOutOfBoundsException e) {
          uvlayers.get(uv).addTVertex(new TVertex(0, 0));
        }
      }
    }
    writer.println("\t}");
    writer.println("\tNormals " + normals.size() + " {");
    for (int i = 0; i < normals.size(); i++) {
      writer.println(tabs + normals.get(i).toString() + ",");
    }
    writer.println("\t}");
    for (int i = 0; i < uvlayers.size(); i++) {
      uvlayers.get(i).printTo(writer, 1, true);
    }
    // Clearing matrix list
    matrix.clear();
    writer.println("\tVertexGroup {");
    for (int i = 0; i < vertex.size(); i++) {
      Matrix newTemp = new Matrix(vertex.get(i).bones);
      boolean newMatrix = true;
      for (int m = 0; m < matrix.size() && newMatrix; m++) {
        if (newTemp.equals(matrix.get(m))) {
          newTemp = matrix.get(m);
          newMatrix = false;
        }
      }
      if (newMatrix) {
        matrix.add(newTemp);
        newTemp.updateIds(mdlr);
      }
      vertex.get(i).VertexGroup = matrix.indexOf(newTemp);
      vertex.get(i).setMatrix(newTemp);
      writer.println(tabs + vertex.get(i).VertexGroup + ",");
    }
    writer.println("\t}");
    if (trianglesTogether) {
      writer.println("\tFaces 1 " + (triangle.size() * 3) + " {");
      writer.println("\t\tTriangles {");
      String triangleOut = "\t\t\t{ ";
      for (int i = 0; i < triangle.size(); i++) {
        triangle.get(i).updateVertexIds(this);
        if (i != triangle.size() - 1) {
          triangleOut = triangleOut + triangle.get(i).toString() + ", ";
        } else {
          triangleOut = triangleOut + triangle.get(i).toString() + " ";
        }
      }
      writer.println(triangleOut + "},");
      writer.println("\t\t}");
    } else {
      writer.println("\tFaces " + triangle.size() + " " + (triangle.size() * 3) + " {");
      writer.println("\t\tTriangles {");
      String triangleOut = "\t\t\t{ ";
      for (int i = 0; i < triangle.size(); i++) {
        triangle.get(i).updateVertexIds(this);
        writer.println(triangleOut + triangle.get(i).toString() + " },");
      }
      writer.println("\t\t}");
    }
    writer.println("\t}");
    int boneRefCount = 0;
    for (int i = 0; i < matrix.size(); i++) {
      boneRefCount += matrix.get(i).bones.size();
    }
    writer.println("\tGroups " + matrix.size() + " " + boneRefCount + " {");
    for (int i = 0; i < matrix.size(); i++) {
      matrix.get(i).updateIds(mdlr);
      matrix.get(i).printTo(writer, 2); // 2 is the tab height
    }
    writer.println("\t}");
    if (extents != null) extents.printTo(writer, 1);
    for (int i = 0; i < anims.size(); i++) {
      anims.get(i).printTo(writer, 1);
    }

    writer.println("\tMaterialID " + materialID + ",");
    writer.println("\tSelectionGroup " + selectionGroup + ",");
    for (int i = 0; i < flags.size(); i++) {
      writer.println("\t" + flags.get(i) + ",");
    }

    writer.println("}");
  }