[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view AbstractView.java,1.24,1.25
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2005-09-08 11:35:17
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27794/src/net/sourceforge/bprocessor/gl/view Modified Files: AbstractView.java Log Message: Change drawContour to ignore surfaces that are not closed Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** AbstractView.java 7 Sep 2005 14:11:34 -0000 1.24 --- AbstractView.java 8 Sep 2005 11:35:06 -0000 1.25 *************** *** 468,566 **** */ private void drawSurface(Surface s) { ! List l = s.getEdges(); ! if (l != null) { ! //Setting up tessellation ! GLUtesselator tess = glu.gluNewTess(); ! GLUtesselatorCallback cb = new Callback(); ! //Setting callbacks ! glu.gluTessCallback(tess, GLU.GLU_TESS_BEGIN, cb); ! glu.gluTessCallback(tess, GLU.GLU_TESS_END, cb); ! glu.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, cb); ! //Contours contained in an even number of contours are filled ! glu.gluTessProperty(tess, GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_ODD); ! //begining the polygon, we are not using userdata for now (hence the null) ! glu.gluTessBeginPolygon(tess, null); ! //light stuff ! if (drawMode == LIGHTING_MODE) { ! Vertex norm = s.normal(); ! norm.scale(1 / norm.length()); ! gl.glNormal3d(norm.getX(), norm.getY(), norm.getZ()); ! } ! //drawing the outer contour ! drawContour(l, tess); ! //drawing the inner conturs ! Set innerSurfaces = s.getInnerSurfaces(); ! if (innerSurfaces != null) { ! Iterator innerIt = innerSurfaces.iterator(); ! while (innerIt.hasNext()) { ! Surface surface = (Surface)innerIt.next(); ! List innerEdges = surface.getEdges(); ! if (innerEdges != null) { ! drawContour(innerEdges, tess); ! } ! } } - - glu.gluTessEndPolygon(tess); - glu.gluDeleteTess(tess); } } /** ! * Draws contours of a surface using the tessellator. ! * @param edges a non-null list of edges describing the contour ! * @param tess the tessellator object */ ! private void drawContour(List edges, GLUtesselator tess) { ! //beginning the contour. ! glu.gluTessBeginContour(tess); ! ! Vertex previous = null; ! Edge previousEdge = null; ! double[] coords; ! for (int i = 0; i < edges.size(); i++) { ! Edge e = (Edge)edges.get(i); ! if (previous == null) { ! previous = e.getTo(); ! // will be drawn with the second vertex as to find out if it is to or from that counts ! } else { ! Vertex temp = e.otherVertex(previous); ! if (temp != null) { ! coords = new double[] {previous.getX(), previous.getY(), previous.getZ()}; ! glu.gluTessVertex(tess, coords, new Point(coords[0], coords[1], coords[2])); ! //gl.glVertex3d(previous.getX(), previous.getY(), previous.getZ()); ! previous = temp; ! if (i == edges.size() - 1) { ! coords = new double[] {previous.getX(), previous.getY(), previous.getZ()}; ! glu.gluTessVertex(tess, coords, new Point(coords[0], coords[1], coords[2])); ! //gl.glVertex3d(previous.getX(), previous.getY(), previous.getZ()); ! } ! } else { ! temp = previousEdge.otherVertex(previous); ! coords = new double[] {temp.getX(), temp.getY(), temp.getZ()}; ! glu.gluTessVertex(tess, coords, new Point(coords[0], coords[1], coords[2])); ! //gl.glVertex3d(temp.getX(), temp.getY(), temp.getZ()); ! previous = e.otherVertex(temp); ! if (i == edges.size() - 1) { ! if (previous == null) { ! log.warn("[drawSurface] could not find vertex " + temp + " on " + e); ! } else { ! coords = new double[] {previous.getX(), previous.getY(), previous.getZ()}; ! glu.gluTessVertex(tess, coords, new Point(coords[0], coords[1], coords[2])); ! //gl.glVertex3d(previous.getX(), previous.getY(), previous.getZ()); ! } ! } ! } } ! previousEdge = e; } - //Ending contour - glu.gluTessEndContour(tess); } /** * Draw an Edge --- 468,529 ---- */ private void drawSurface(Surface s) { ! GLUtesselator tess = glu.gluNewTess(); ! GLUtesselatorCallback cb = new Callback(); ! //Setting callbacks ! glu.gluTessCallback(tess, GLU.GLU_TESS_BEGIN, cb); ! glu.gluTessCallback(tess, GLU.GLU_TESS_END, cb); ! glu.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, cb); ! //Contours contained in an even number of contours are filled ! glu.gluTessProperty(tess, GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_ODD); ! //begining the polygon, we are not using userdata for now (hence the null) ! glu.gluTessBeginPolygon(tess, null); ! //light stuff ! if (drawMode == LIGHTING_MODE) { ! Vertex norm = s.normal(); ! norm.scale(1 / norm.length()); ! gl.glNormal3d(norm.getX(), norm.getY(), norm.getZ()); ! } ! //drawing the outer contour ! drawContour(s, tess); ! //drawing the inner conturs ! Set innerSurfaces = s.getInnerSurfaces(); ! if (innerSurfaces != null) { ! Iterator innerIt = innerSurfaces.iterator(); ! while (innerIt.hasNext()) { ! Surface surface = (Surface)innerIt.next(); ! drawContour(surface, tess); } } + + glu.gluTessEndPolygon(tess); + glu.gluDeleteTess(tess); } /** ! * Draw contour of a Surface. ! * @param surface The surface ! * @param tess The Tesselator */ ! private void drawContour(Surface surface, GLUtesselator tess) { ! List vertices = surface.getVertices(); ! Vertex first = (Vertex) vertices.get(0); ! Vertex last = (Vertex) vertices.get(vertices.size() - 1); ! if (first == last) { ! Iterator iter = vertices.iterator(); ! glu.gluTessBeginContour(tess); ! while (iter.hasNext()) { ! Vertex current = (Vertex) iter.next(); ! double[] coords = new double[] {current.getX(), current.getY(), current.getZ()}; ! glu.gluTessVertex(tess, coords, new Point(coords[0], coords[1], coords[2])); } ! glu.gluTessEndContour(tess); } } + /** * Draw an Edge |