/** * @param path Path of the .obj file * @param index GLUint */ public static void name(String path, int index) { int list = glGenLists(index); glNewList(list, GL_COMPILE); { Model m = null; try { m = OBJLoader.loadModel(new File(path)); } catch (FileNotFoundException e) { e.printStackTrace(); Display.destroy(); System.exit(1); } catch (IOException e) { e.printStackTrace(); Display.destroy(); System.exit(1); } float b; // glColor3f(0.3f, 0.20f, 0.13f); b = (float) Math.random(); glColor3f(b, 0, 0); int count = 0; glBegin(GL_TRIANGLES); for (Face face : m.faces) { count++; Vector3f n1 = m.normals.get((int) face.normal.x - 1); glNormal3f(n1.x, n1.y, n1.z); Vector3f v1 = m.vertices.get((int) face.vertex.x - 1); glVertex3f(v1.x, v1.y, v1.z); Vector3f n2 = m.normals.get((int) face.normal.y - 1); glNormal3f(n2.x, n2.y, n2.z); Vector3f v2 = m.vertices.get((int) face.vertex.y - 1); glVertex3f(v2.x, v2.y, v2.z); Vector3f n3 = m.normals.get((int) face.normal.z - 1); glNormal3f(n3.x, n3.y, n3.z); Vector3f v3 = m.vertices.get((int) face.vertex.z - 1); glVertex3f(v3.x, v3.y, v3.z); } glEnd(); System.out.println(count); } glEndList(); }