GL11.glEnable(GL11.GL_NORMALIZE);
GL11.glBegin(GL11.GL_TRIANGLES);
for (int i = 0; i < bodies.length - 1; ++i) {
for (int j = 0; j < bodies[i].length - 1; ++j) {
DVector3C vec0 = bodies[i][j].getPosition();
DVector3C vec1 = bodies[i + 1][j].getPosition();
DVector3C vec2 = bodies[i][j + 1].getPosition();
DVector3C vec3 = bodies[i + 1][j + 1].getPosition();
DVector3C temp1 = new DVector3(vec1.get0() - vec0.get0(),
vec1.get1() - vec0.get1(), vec1.get2() - vec0.get2());
DVector3C temp2 = new DVector3(vec2.get0() - vec0.get0(),
vec2.get1() - vec0.get1(), vec2.get2() - vec0.get2());
DVector3C temp3 = new DVector3(vec1.get0() - vec2.get0(),
vec1.get1() - vec2.get1(), vec1.get2() - vec2.get2());
DVector3C temp4 = new DVector3(vec3.get0() - vec2.get0(),
vec3.get1() - vec2.get1(), vec3.get2() - vec2.get2());
DVector3C normal = new DVector3(temp1.get1() * temp2.get2()
- temp1.get2() * temp2.get1(), temp1.get2()
* temp2.get0() - temp1.get0() * temp2.get2(),
temp1.get0() * temp2.get1() - temp1.get1()
* temp2.get0());
DVector3C normal2 = new DVector3(temp3.get1() * temp4.get2()
- temp3.get2() * temp4.get1(), temp3.get2()
* temp4.get0() - temp3.get0() * temp4.get2(),
temp3.get0() * temp4.get1() - temp3.get1()
* temp4.get0());
DVector3C norm0 = normal.clone();
DVector3C norm1 = normal.clone();
DVector3C norm2 = normal.clone();
DVector3C norm3 = normal.clone();
norm1 = new DVector3(norm1.get0() + normal2.get0(),
norm1.get1() + normal2.get1(), norm1.get2()
+ normal2.get2());
norm2 = new DVector3(norm2.get0() + normal2.get0(),
norm2.get1() + normal2.get1(), norm2.get2()
+ normal2.get2());
norm3 = new DVector3(norm3.get0() + normal2.get0(),
norm3.get1() + normal2.get1(), norm3.get2()
+ normal2.get2());
GL11.glNormal3d(norm0.get0(), norm0.get1(), norm0.get2());
GL11.glVertex3d(vec0.get0(), vec0.get1(), vec0.get2());
GL11.glNormal3d(norm1.get0(), norm1.get1(), norm1.get2());
GL11.glVertex3d(vec1.get0(), vec1.get1(), vec1.get2());
GL11.glNormal3d(norm2.get0(), norm2.get1(), norm2.get2());
GL11.glVertex3d(vec2.get0(), vec2.get1(), vec2.get2());
GL11.glNormal3d(norm2.get0(), norm2.get1(), norm2.get2());
GL11.glVertex3d(vec2.get0(), vec2.get1(), vec2.get2());
GL11.glNormal3d(norm1.get0(), norm1.get1(), norm1.get2());
GL11.glVertex3d(vec1.get0(), vec1.get1(), vec1.get2());
GL11.glNormal3d(norm3.get0(), norm3.get1(), norm3.get2());
GL11.glVertex3d(vec3.get0(), vec3.get1(), vec3.get2());
}
}
GL11.glEnd();
GL11.glDisable(GL11.GL_NORMALIZE);
GL11.glDisable(GL11.GL_LIGHTING);
// GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glLightModeli(GL11.GL_LIGHT_MODEL_TWO_SIDE, GL11.GL_FALSE);
// / GRID
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glLineWidth(2);
GL11.glEnable(GL11.GL_LINE_STIPPLE);
// GL11.glShadeModel(GL11.GL_FLAT);
GL11.glColor3f(.085f, .085f, .085f);
GL11.glBegin(GL11.GL_LINES);
for (int i = 0; i < bodies.length - 1; ++i) {
for (int j = 0; j < bodies[i].length - 1; ++j) {
DVector3C vec0 = bodies[i][j].getPosition();
DVector3C vec1 = bodies[i][j + 1].getPosition();
DVector3C vec2 = bodies[i + 1][j].getPosition();
GL11.glVertex3d(vec0.get0(), vec0.get1(), vec0.get2());
GL11.glVertex3d(vec1.get0(), vec1.get1(), vec1.get2());
GL11.glVertex3d(vec0.get0(), vec0.get1(), vec0.get2());
GL11.glVertex3d(vec2.get0(), vec2.get1(), vec2.get2());
}
}
for (int i = 0; i < bodies.length - 1; i++) {
DVector3C vec0 = bodies[i][bodies[i].length - 1].getPosition();
DVector3C vec1 = bodies[i + 1][bodies[i + 1].length - 1]
.getPosition();
GL11.glVertex3d(vec0.get0(), vec0.get1(), vec0.get2());
GL11.glVertex3d(vec1.get0(), vec1.get1(), vec1.get2());
}
for (int i = 0; i < bodies.length - 1; i++) {
DVector3C vec0 = bodies[bodies[i].length - 1][i].getPosition();
DVector3C vec1 = bodies[bodies[i + 1].length - 1][i + 1]
.getPosition();
GL11.glVertex3d(vec0.get0(), vec0.get1(), vec0.get2());
GL11.glVertex3d(vec1.get0(), vec1.get1(), vec1.get2());
}
GL11.glEnd();
}