示例#1
0
  /* Generate a Triangle mesh that represents this Box. */
  private void buildMesh() {
    // Create the OBJMesh
    MeshData box = new MeshData();

    box.vertexCount = 8;
    box.indexCount = 36;

    // Add positions
    box.positions = BufferUtils.createFloatBuffer(box.vertexCount * 3);
    box.positions.put(
        new float[] {
          (float) minPt.x, (float) minPt.y, (float) minPt.z,
          (float) minPt.x, (float) maxPt.y, (float) minPt.z,
          (float) maxPt.x, (float) maxPt.y, (float) minPt.z,
          (float) maxPt.x, (float) minPt.y, (float) minPt.z,
          (float) minPt.x, (float) minPt.y, (float) maxPt.z,
          (float) minPt.x, (float) maxPt.y, (float) maxPt.z,
          (float) maxPt.x, (float) maxPt.y, (float) maxPt.z,
          (float) maxPt.x, (float) minPt.y, (float) maxPt.z
        });

    box.indices = BufferUtils.createIntBuffer(box.indexCount);
    box.indices.put(
        new int[] {
          0, 1, 2, 0, 2, 3, 0, 5, 1, 0, 4, 5, 0, 7, 4, 0, 3, 7, 4, 6, 5, 4, 7, 6, 2, 5, 6, 2, 1, 5,
          2, 6, 7, 2, 7, 3
        });
    this.mesh = new Mesh(box);

    // set transformations and absorptioins
    this.mesh.setTransformation(this.tMat, this.tMatInv, this.tMatTInv);

    this.mesh.shader = this.shader;
  }