Пример #1
0
  /** Dumps the data of this 3d shape. */
  public String toString() {
    StringBuffer sb = new StringBuffer();

    // number of polygons
    sb.append(polygons.length + "\n");

    // loop - one line per polygon
    for (int i = 0; i < polygons.length; i++) {
      Polygon po = polygons[i];

      // todo: tidy up shadows - what a mess !
      boolean shadow = false;
      for (int j = 0; j < MAX_SHADOWS; j++) {
        if (shadowCasters[j] == i) {
          shadow = true;
          break;
        }
      }
      sb.append(shadow ? "t " : "f ");

      sb.append(po.doubleSided ? "t " : "f ");

      int rgb = po.c.getRGB();
      sb.append("\"" + Integer.toHexString(rgb & 0xFFFFFF) + "\" ");

      // loop - points in this polygon
      for (int j = 0; j < po.n; j++) {
        int index = po.points[j];
        sb.append(
            Tools3d.round(ps[index])
                + " "
                + Tools3d.round(ps[index + 1])
                + " "
                + Tools3d.round(ps[index + 2])
                + ", ");
      }

      // finished this polygon so end line
      sb.append("\n");
    }
    return new String(sb);
  }