[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view Display.java, 1.2, 1.3
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-09-23 18:20:32
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6068/src/net/sourceforge/bprocessor/gl/view Modified Files: Display.java Log Message: Progress on new display mechanism Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Display.java 23 Sep 2007 16:02:08 -0000 1.2 --- Display.java 23 Sep 2007 18:20:26 -0000 1.3 *************** *** 9,12 **** --- 9,13 ---- import java.util.Collection; + import java.util.Collections; import java.util.HashSet; import java.util.LinkedList; *************** *** 22,25 **** --- 23,27 ---- import net.sourceforge.bprocessor.model.Camera; + import net.sourceforge.bprocessor.model.Defaults; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Geometric; *************** *** 41,46 **** private static float[] white = new float[] {1.0f, 1.0f, 1.0f}; private static float[] black = new float[] {0.0f, 0.0f, 0.0f}; ! ! /** * --- 43,48 ---- private static float[] white = new float[] {1.0f, 1.0f, 1.0f}; private static float[] black = new float[] {0.0f, 0.0f, 0.0f}; ! private static float[] blueish = new float[] {0.1f, 0.2f, 0.5f}; ! private static float[] redish = new float[] {0.5f, 0.2f, 0.1f}; /** * *************** *** 96,121 **** private static void drawSurfaces(Collection<Surface> surfaces) { ! gl.glColor3fv(white, 0); gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); gl.glPolygonOffset(0.5f, 0.5f); for (Surface current : surfaces) { ! draw(current); } gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); } ! private static void draw(Surface surface) { glu.gluTessBeginPolygon(tesselator, null); ! drawContour(surface); for (Surface current : surface.getHoles()) { ! drawContour(current); } glu.gluTessEndPolygon(tesselator); } ! private static void drawContour(Surface surface) { List<Vertex> vertices = surface.getVertices(); if (vertices.size() > 2) { vertices.add(vertices.get(0)); glu.gluTessBeginContour(tesselator); for (Vertex current : vertices) { --- 98,149 ---- private static void drawSurfaces(Collection<Surface> surfaces) { ! gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); gl.glPolygonOffset(0.5f, 0.5f); + gl.glEnable(GL.GL_CULL_FACE); + gl.glCullFace(GL.GL_BACK); for (Surface current : surfaces) { ! Space front = current.getFrontDomain(); ! Vertex n = current.normal(); ! gl.glNormal3d(n.getX(), n.getY(), n.getZ()); ! if (front.isConstructionSpace()) { ! gl.glColor3fv(Defaults.getFrontColor(), 0); ! } else { ! gl.glColor3fv(Defaults.getBackColor(), 0); ! } ! draw(current, false); ! } ! for (Surface current : surfaces) { ! Space back = current.getBackDomain(); ! Vertex n = current.normal(); ! gl.glNormal3d(-n.getX(), -n.getY(), -n.getZ()); ! if (back.isConstructionSpace()) { ! gl.glColor3fv(Defaults.getFrontColor(), 0); ! } else { ! gl.glColor3fv(Defaults.getBackColor(), 0); ! } ! draw(current, true); } gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); + gl.glDisable(GL.GL_CULL_FACE); + gl.glDisable(GL.GL_LIGHTING); } ! private static void draw(Surface surface, boolean reverse) { glu.gluTessBeginPolygon(tesselator, null); ! drawContour(surface, reverse); for (Surface current : surface.getHoles()) { ! drawContour(current, false); } glu.gluTessEndPolygon(tesselator); } ! private static void drawContour(Surface surface, boolean reverse) { List<Vertex> vertices = surface.getVertices(); if (vertices.size() > 2) { vertices.add(vertices.get(0)); + if (reverse) { + Collections.reverse(vertices); + } glu.gluTessBeginContour(tesselator); for (Vertex current : vertices) { |