Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view Display.java, 1.8, 1.9
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-09-24 18:44:45
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32008/src/net/sourceforge/bprocessor/gl/view Modified Files: Display.java Log Message: Refactoring of unified display Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Display.java 24 Sep 2007 14:40:34 -0000 1.8 --- Display.java 24 Sep 2007 18:44:40 -0000 1.9 *************** *** 37,40 **** --- 37,43 ---- */ public class Display { + + private static final boolean TRUE = true; + private static boolean initialized; private static boolean selecting; *************** *** 148,154 **** private static void selectSurfaces(Collection<Surface> surfaces) { for (Surface current : surfaces) { ! push(current); ! draw(current, false); ! pop(); } } --- 151,159 ---- private static void selectSurfaces(Collection<Surface> surfaces) { for (Surface current : surfaces) { ! if (!transparent(current)) { ! push(current); ! draw(current, false); ! pop(); ! } } } *************** *** 161,184 **** 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); --- 166,193 ---- gl.glCullFace(GL.GL_BACK); for (Surface current : surfaces) { ! if (!transparent(current)) { ! 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) { ! if (!transparent(current)) { ! 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); *************** *** 265,269 **** private static boolean transparent(Space space) { ! return (space.isFunctionalSpace() || space.isTransparent() || !space.getSurfaces().isEmpty()); } --- 274,293 ---- private static boolean transparent(Space space) { ! Project project = Project.getInstance(); ! Camera camera = project.getCurrentCamera(); ! Collection<Geometric> hidden = camera.getHiddenGeometrics(); ! if (hidden.contains(space)) { ! return true; ! } ! if (space.isTransparent()) { ! return true; ! } ! if (!space.getSurfaces().isEmpty()) { ! return true; ! } ! if (space.isFunctionalSpace()) { ! return true; ! } ! return false; } *************** *** 289,319 **** Set<Geometric> hidden = new HashSet(); hidden.addAll(camera.getHiddenGeometrics()); - Collection<Space> elements = new LinkedList(); - for (Space current : space.getElements()) { - if (hidden.contains(current)) { - if (!transparent(current)) { - for (Surface surface : current.getEnvelope()) { - Space front = surface.getFrontDomain(); - Space back = surface.getBackDomain(); - if (front == back) { - hidden.add(surface); - } else { - Space other = null; - if (front == current) { - other = back; - } else { - other = front; - } - if (hidden.contains(other) || transparent(other)) { - hidden.add(surface); - } - } - } - } - } else { - elements.add(current); - } - } Collection<Surface> surfaces = new LinkedList(); Collection<Edge> edges = new LinkedList(); --- 313,318 ---- Set<Geometric> hidden = new HashSet(); hidden.addAll(camera.getHiddenGeometrics()); + Collection<Space> elements = new LinkedList(); Collection<Surface> surfaces = new LinkedList(); Collection<Edge> edges = new LinkedList(); *************** *** 321,371 **** Collection<Vertex> loners = new LinkedList(); { ! Set<Edge> mark = new HashSet(); ! Set<Edge> visible = new HashSet(); ! for (Surface current : space.getSurfaces()) { ! mark.addAll(current.getEdges()); if (!hidden.contains(current)) { if (!transparent(current)) { surfaces.add(current); - visible.addAll(current.getEdges()); - for (Surface hole : current.getHoles()) { - visible.addAll(hole.getEdges()); - } } } } ! for (Edge current : space.getEdges()) { ! if (mark.contains(current)) { ! if (visible.contains(current)) { ! edges.add(current); ! } ! } else { edges.add(current); } } } - { ! Set<Vertex> connected = new HashSet(); ! Set<Vertex> mark = new HashSet(); ! for (Edge current : space.getEdges()) { ! connected.add(current.getFrom()); ! connected.add(current.getTo()); ! } for (Edge current : edges) { ! mark.add(current.getFrom()); ! mark.add(current.getTo()); } ! for (Vertex current : space.getVertices()) { ! if (!connected.contains(current)) { ! loners.add(current); ! vertices.add(current); ! } else if (mark.contains(current)) { vertices.add(current); } } } ! gl.glEnable(GL.GL_DEPTH_TEST); --- 320,371 ---- Collection<Vertex> loners = new LinkedList(); + + + for (Space current : space.getElements()) { + if (!hidden.contains(current)) { + elements.add(current); + } + } { ! Set<Surface> visible = new HashSet(); ! for (Space current : elements) { ! visible.addAll(current.getEnvelope()); ! } ! for (Surface current : visible) { if (!hidden.contains(current)) { if (!transparent(current)) { surfaces.add(current); } } } ! } ! { ! Set<Edge> visible = new HashSet(); ! for (Surface current : surfaces) { ! visible.addAll(current.getEdges()); ! for (Surface hole : current.getHoles()) { ! visible.addAll(hole.getEdges()); ! } ! } ! for (Edge current : visible) { ! if (!hidden.contains(current)) { edges.add(current); } } } { ! Set<Vertex> visible = new HashSet(); for (Edge current : edges) { ! visible.add(current.getFrom()); ! visible.add(current.getTo()); } ! for (Vertex current : visible) { ! if (!hidden.contains(current)) { vertices.add(current); } } } ! ! gl.glEnable(GL.GL_DEPTH_TEST); |