Exemplo n.º 1
0
 @Override
 public Model clone() {
   Model model = new Model();
   for (Mesh mesh : meshes) model.meshes.add(mesh.clone());
   model.render_normals = render_normals;
   model.render_wireframe = render_wireframe;
   return model;
 }
Exemplo n.º 2
0
 public void tessellate() {
   Tessellator.instance.startDrawing(GL11.GL_TRIANGLES);
   for (Mesh m : meshes) {
     for (Face face : m.getFaces()) {
       tessVert(m, face, 0);
       tessVert(m, face, 1);
       tessVert(m, face, 2);
     }
   }
   Tessellator.instance.draw();
 }
Exemplo n.º 3
0
  public void render() {
    if (render_wireframe) GL11.glBegin(GL11.GL_LINE_LOOP);
    else GL11.glBegin(GL11.GL_TRIANGLES);

    for (Mesh m : meshes) {
      for (Face face : m.getFaces()) {
        try {

          // One
          renderVert(m, face, 0);

          // Two
          renderVert(m, face, 1);

          // Three
          renderVert(m, face, 2);
        } catch (ArrayIndexOutOfBoundsException e) {
          e.printStackTrace();
        }
      }
    }
    GL11.glEnd();

    if (render_normals) {
      GL11.glColor3f(Color.BLUE.getRed(), Color.BLUE.getGreen(), Color.BLUE.getBlue());
      for (Mesh m : meshes) {
        for (Face face : m.getFaces()) {
          Vert center =
              center2(
                  m.vertices.get(face.vertexIndices[0]),
                  m.vertices.get(face.vertexIndices[1]),
                  m.vertices.get(face.vertexIndices[2]));
          Vert out = center.add(m.normals.get(face.normalIndices[0]));

          GL11.glBegin(GL11.GL_LINE_LOOP);
          GL11.glVertex3f(center.xf(), center.yf(), center.zf());
          GL11.glVertex3f(out.xf(), out.yf(), out.zf());
          GL11.glEnd();
        }
      }
    }
  }
Exemplo n.º 4
0
  protected void renderVert(Mesh m, Face face, int i) {
    Vert n1 = m.normals.get(face.normalIndices[i]);
    GL11.glNormal3f(n1.xf(), n1.yf(), n1.zf());

    Vert v1 = m.getVertices().get(face.vertexIndices[i]);
    GL11.glVertex3f(v1.xf(), v1.yf(), v1.zf());

    if (m.textureCoordinates.size() >= face.textureCoordinateIndices[i]) {
      UVPoint t1 = m.textureCoordinates.get(face.textureCoordinateIndices[i]);
      GL11.glTexCoord2f(t1.xf(), t1.yf());
    }
  }