[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view Display.java, 1.71, 1.72
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-12-18 08:02:54
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv785/src/net/sourceforge/bprocessor/gl/view Modified Files: Display.java Log Message: material Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** Display.java 17 Dec 2007 14:20:41 -0000 1.71 --- Display.java 18 Dec 2007 08:02:58 -0000 1.72 *************** *** 28,31 **** --- 28,32 ---- import net.sourceforge.bprocessor.gl.model.GlObject; + import net.sourceforge.bprocessor.model.Material; import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Camera; *************** *** 33,37 **** import net.sourceforge.bprocessor.model.Constructor; import net.sourceforge.bprocessor.model.CoordinateSystem; - import net.sourceforge.bprocessor.model.Defaults; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Geometric; --- 34,37 ---- *************** *** 380,383 **** --- 380,392 ---- } + private static void apply(Material material) { + float[] color = material.getColor(); + float[] ambient = material.getAmbientColor(); + float[] diffuse = material.getDiffuseColor(); + gl.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, color, 0); + gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, ambient, 0); + gl.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, diffuse, 0); + } + private static void draw(Vertex vertex) { gl.glBegin(GL.GL_POINTS); *************** *** 483,494 **** } ! private static float[] colorOf(Container space) { ! if (space.isVoid()) { ! return Defaults.getVoidMaterial().getColor(); ! } else if (space.isConstructionSpace()) { ! return Defaults.getConstructionMaterial().getColor(); ! } else { ! return Defaults.getFunctionalMaterial().getColor(); ! } } --- 492,503 ---- } ! private static float[] frontColor(Surface surface) { ! Material material = surface.frontMaterial(); ! return material.getColor(); ! } ! ! private static float[] backColor(Surface surface) { ! Material material = surface.backMaterial(); ! return material.getColor(); } *************** *** 504,511 **** gl.glCullFace(GL.GL_BACK); for (Surface current : surfaces) { - Container front = current.getFrontDomain(); Vertex n = current.normal(); gl.glNormal3d(n.getX(), n.getY(), n.getZ()); ! float[] color = colorOf(front); if (!transparent(current)) { paint(current, color, 1.0f, false); --- 513,519 ---- gl.glCullFace(GL.GL_BACK); for (Surface current : surfaces) { Vertex n = current.normal(); gl.glNormal3d(n.getX(), n.getY(), n.getZ()); ! float[] color = frontColor(current); if (!transparent(current)) { paint(current, color, 1.0f, false); *************** *** 515,522 **** } for (Surface current : surfaces) { - Container back = current.getBackDomain(); Vertex n = current.normal(); gl.glNormal3d(-n.getX(), -n.getY(), -n.getZ()); ! float[] color = colorOf(back); if (!transparent(current)) { paint(current, color, 1.0f, true); --- 523,529 ---- } for (Surface current : surfaces) { Vertex n = current.normal(); gl.glNormal3d(-n.getX(), -n.getY(), -n.getZ()); ! float[] color = backColor(current); if (!transparent(current)) { paint(current, color, 1.0f, true); *************** *** 543,546 **** --- 550,559 ---- } + private static void paint(Surface surface, Material material, boolean reverse) { + apply(material); + draw(surface, reverse); + } + + private static void drawQuad(Surface surface, boolean reverse) { List<Vertex> vertices = surface.getVertices(); |