[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view View.java,1.78,1.79
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-05-02 07:09:45
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17045/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Log Message: Small fixes to the space-drawing algorithm Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** View.java 13 Apr 2006 13:55:23 -0000 1.78 --- View.java 2 May 2006 07:09:38 -0000 1.79 *************** *** 693,767 **** } ! { ! if (DRAW_LONE_VERTICES) { ! // Draw any Vertex that are not part of an edge ! Collection vertices = Project.getInstance().getVertices(); ! gl.glColor3fv(lineColor); ! Iterator it = vertices.iterator(); ! while (it.hasNext()) { ! Vertex v = (Vertex)it.next(); ! if (v.getEdges().isEmpty()) { ! gl.glColor3fv(lineColor); ! gl.glPointSize(5.0f); ! gl.glBegin(GL.GL_POINTS); ! gl.glVertex3d(v.getX(), v.getY(), v.getZ()); ! gl.glEnd(); ! gl.glPointSize(1.0f); ! } ! } ! // Draw any temporary vertex not part of an edge ! gl.glColor3fv(lineColor); ! it = tempVertices.iterator(); ! while (it.hasNext()) { ! Vertex v = (Vertex)it.next(); ! if (v.getEdges().isEmpty()) { ! gl.glColor3fv(lineColor); ! gl.glPointSize(5.0f); ! gl.glBegin(GL.GL_POINTS); ! gl.glVertex3d(v.getX(), v.getY(), v.getZ()); ! gl.glEnd(); ! gl.glPointSize(1.0f); ! } ! } ! } } - // Fill surfaces - switch (drawMode) { - case LIGHTING_MODE: { - 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); - gl.glColor3fv(Defaults.getFrontColor()); - drawSurfaces(gld, FRONT); - - gl.glCullFace(GL.GL_FRONT); - gl.glColor3fv(Defaults.getBackColor()); - drawSurfaces(gld, BACK); - - gl.glDisable(GL.GL_CULL_FACE); - gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); - gl.glDisable(GL.GL_LIGHTING); - break; - } - case WIREFRAME_MODE: { - // NOTHING TO DO - break; - } - case SOLID_MODE: { - gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); - gl.glPolygonOffset(1.0f, 1.0f); - gl.glColor3fv(SURFACE_COLOR); - drawSurfaces(gld, BOTH); - gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); - break; - } - } //Draw edges if (doDrawEdges) { ! drawEdges(gld); } --- 693,706 ---- } ! Space active = Project.getInstance().getActiveSpace(); ! if (active != null) { ! drawSpace(active, gld); ! } else { ! drawSpace(Project.getInstance().world(), gld); } //Draw edges if (doDrawEdges) { ! drawEdges(gld); } *************** *** 845,848 **** --- 784,839 ---- } + /** + * Draw space + * @param gld GLDrawable + * @param space The Space + */ + private void drawSpace(Space space, GLDrawable gld) { + + Collection surfaces = space.getSurfaces(); + switch (drawMode) { + case LIGHTING_MODE: { + 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); + gl.glColor3fv(Defaults.getFrontColor()); + drawSurfaces(gld, surfaces, FRONT); + + gl.glCullFace(GL.GL_FRONT); + gl.glColor3fv(Defaults.getBackColor()); + drawSurfaces(gld, surfaces, BACK); + + gl.glDisable(GL.GL_CULL_FACE); + gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); + gl.glDisable(GL.GL_LIGHTING); + break; + } + case WIREFRAME_MODE: { + // NOTHING TO DO + break; + } + case SOLID_MODE: { + gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); + gl.glPolygonOffset(1.0f, 1.0f); + gl.glColor3fv(SURFACE_COLOR); + drawSurfaces(gld, surfaces, BOTH); + gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); + break; + } + } + if (doDrawEdges) { + drawGeneralEdges(gld, space.getEdges()); + } + Collection elements = space.getElements(); + Iterator iter = elements.iterator(); + while (iter.hasNext()) { + Space current = (Space) iter.next(); + drawSpace(current, gld); + } + } + /** *************** *** 895,899 **** /** ! * Draww all edges * @param gld The GLDrawable */ --- 886,890 ---- /** ! * Draw all edges * @param gld The GLDrawable */ *************** *** 923,929 **** } drawConstructionEdges(gld, edges); - drawGeneralEdges(gld, active.getEdges()); - } else { - drawGeneralEdges(gld, all); } } --- 914,917 ---- *************** *** 999,1002 **** --- 987,999 ---- /** + * + * @param surface The surface + * @return True if surface is hidden + */ + private boolean hide(Surface surface) { + return false; + } + + /** * Draw the surfaces * @param gld The GLDrawable *************** *** 1005,1014 **** */ private void drawSurfaces(GLDrawable gld, Collection surfaces, int side) { - Collection selection = glv.getTool().getSelection(); GL gl = gld.getGL(); Iterator it = surfaces.iterator(); while (it.hasNext()) { Surface s = (Surface)it.next(); ! if (!selection.contains(s)) { boolean visible = isVisible(s); if (side == BOTH) { --- 1002,1010 ---- */ private void drawSurfaces(GLDrawable gld, Collection surfaces, int side) { GL gl = gld.getGL(); Iterator it = surfaces.iterator(); while (it.hasNext()) { Surface s = (Surface)it.next(); ! if (!hide(s)) { boolean visible = isVisible(s); if (side == BOTH) { *************** *** 1622,1625 **** --- 1618,1630 ---- /** + * + * @param space The space + * @return True if empty + */ + private boolean isVisible(Space space) { + return (space.isConstructionSpace() && space.getSurfaces().isEmpty()); + } + + /** * Is the surface visible * @param surface The surface to test *************** *** 1629,1648 **** Space back = surface.getBackDomain(); Space front = surface.getFrontDomain(); ! if (front == null) { ! return true; ! } ! if (back == null) { return true; } - if ((front.isFunctionalSpace()) && (back.isFunctionalSpace())) { - return false; - } if (front == back) { return false; } ! if (!front.getSurfaces().isEmpty() || !back.getSurfaces().isEmpty()) { ! return false; ! } ! return true; } --- 1634,1644 ---- Space back = surface.getBackDomain(); Space front = surface.getFrontDomain(); ! if (front == null || back == null) { return true; } if (front == back) { return false; } ! return (isVisible(front) || isVisible(back)); } |