Esempio n. 1
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());
    }
  }
Esempio n. 2
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();
        }
      }
    }
  }
Esempio n. 3
0
 protected void tessVert(Mesh m, Face face, int i) {
   Vert n1 = m.vertices.get(face.vertexIndices[i]);
   UVPoint t1 = m.textureCoordinates.get(face.textureCoordinateIndices[i]);
   Tessellator.instance.addVertexWithUV(n1.xf(), n1.yf(), n1.zf(), t1.xf(), t1.yf());
 }
Esempio n. 4
0
 static Vert center2(Vert v1, Vert v2, Vert v3) {
   return v1.add(v2).add(v3).divide(3);
 }