Hi,
Thanks for helping me figure out the previous question about lighting.
I’m still having trouble giving the back side of polygons a color different from the front side. The same sphere (with fixed lighting!) with half the triangles missing so you can see through can be found.
http://www.geocities.com/bura3no/index.htm
The relevant code is here:
gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, Color.GREEN.getComponents(null) );
gl.glMaterialfv(GL.GL_BACK, GL.GL_AMBIENT_AND_DIFFUSE, Color.RED.getComponents(null) );
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, Color.BLACK.getComponents(null));
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, Color.WHITE.getComponents(null) );
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
gl.glBegin(GL.GL_TRIANGLES);
for (int t = 0; t < myMesh.pGetNumberOfElements()/2; t++) {
Element elem = myMesh.pGetElement(t);
for (int v = 0; v < elem.pGetNumberOfNodes(); v++) {
VDouble x = myMesh.pGetX(elem.pGetNode(v));
VDouble n = normals[elem.pGetNode(v)];
gl.glNormal3d(n.pGet(0), n.pGet(1), n.pGet(2));
gl.glVertex3d(x.pGet(0), x.pGet(1), x.pGet(2));
}
}
gl.glEnd();
}
gl.glEndList();