[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view View.java, 1.159, 1.160
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-11-07 10:51:21
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31909/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Log Message: changes to clippingplane tool and visualization Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.159 retrieving revision 1.160 diff -C2 -d -r1.159 -r1.160 *** View.java 30 Oct 2006 10:31:51 -0000 1.159 --- View.java 7 Nov 2006 10:51:19 -0000 1.160 *************** *** 669,673 **** if (cp.isActive()) { gl.glDisable(GL.GL_CLIP_PLANE0 + cp.getNumber()); ! if (cp.getClipdepth() != 0) { gl.glDisable(GL.GL_CLIP_PLANE5); } --- 669,673 ---- if (cp.isActive()) { gl.glDisable(GL.GL_CLIP_PLANE0 + cp.getNumber()); ! if (cp.isSlice()) { gl.glDisable(GL.GL_CLIP_PLANE5); } *************** *** 686,689 **** --- 686,694 ---- gl.glClipPlane(GL.GL_CLIP_PLANE0 + cp.getNumber(), cp.getPlane().getDoublev()); gl.glEnable(GL.GL_CLIP_PLANE0 + cp.getNumber()); + if (cp.isSlice()) { + gl.glClipPlane(GL.GL_CLIP_PLANE5, cp.getPlane().negate().getDoublev()); + gl.glEnable(GL.GL_CLIP_PLANE5); + cp.getPlane().negate(); + } } } *************** *** 940,950 **** gl.glColor3fv(targetColor); gl.glLineWidth(1.5f); drawGeometric((Geometric) target); } - - CoordinateSystem cs = Project.getInstance().getActiveCoordinateSystem(); - //grid(cs); - drawConstructorPlanes(); --- 945,960 ---- gl.glColor3fv(targetColor); gl.glLineWidth(1.5f); + // If target is a snap vertex it should be shown regardless of the clip + if (target instanceof Vertex) { + disableClipplanes(); + } + drawGeometric((Geometric) target); + // remember to enable clip again + if (target instanceof Vertex) { + enableClipplanes(); + } } drawConstructorPlanes(); *************** *** 1167,1171 **** --- 1177,1183 ---- */ private void drawEdges(GLDrawable gld) { + disableClipplanes(); drawGeneralEdges(gld, tempEdges); + enableClipplanes(); Space active = Project.getInstance().getActiveSpace(); if (active != Project.getInstance().world()) { *************** *** 1197,1200 **** --- 1209,1213 ---- */ private void drawConstructors() { + disableClipplanes(); Space active = Project.getInstance().getActiveSpace(); Camera camera = Project.getInstance().getCurrentCamera(); *************** *** 1203,1208 **** double dist = v.minus(new Vertex(camera.getCenter())).length() * scale; if (active != null) { - // Should be drawn regardless of clipplanes - disableClipplanes(); gl.glPushMatrix(); transformTo(active); --- 1216,1219 ---- *************** *** 1211,1215 **** grid(Project.getInstance().getActiveCoordinateSystem()); gl.glPopMatrix(); - enableClipplanes(); } while (true) { --- 1222,1225 ---- *************** *** 1245,1248 **** --- 1255,1259 ---- drawGeneralConstructor(c, dist, true, OBJECTS); } + enableClipplanes(); } *************** *** 1997,2015 **** gl.glPopMatrix(); } ! { ! Iterator it = Project.getInstance().getCurrentCamera().getClipplanes().iterator(); ! while (it.hasNext()) { ! ClippingPlane cp = (ClippingPlane)it.next(); ! gl.glDisable(GL.GL_CLIP_PLANE0 + cp.getNumber()); ! } ! } if (selectMode == CLIPPLANES || selectMode == ALL) { { Iterator it = Project.getInstance().getCurrentCamera().getClipplanes().iterator(); ! while (it.hasNext()) { ! ClippingPlane cp = (ClippingPlane)it.next(); ! pushName(gl, cp); ! drawClipplane(cp); ! popName(gl); } } --- 2008,2027 ---- gl.glPopMatrix(); } ! disableClipplanes(); if (selectMode == CLIPPLANES || selectMode == ALL) { { Iterator it = Project.getInstance().getCurrentCamera().getClipplanes().iterator(); ! if (selectionMode == INTERSECTIONS) { ! while (it.hasNext()) { ! ClippingPlane cp = (ClippingPlane)it.next(); ! drawClipplaneIntersection(cp); ! } ! } else { ! while (it.hasNext()) { ! ClippingPlane cp = (ClippingPlane)it.next(); ! pushName(gl, cp); ! drawClipplane(cp); ! popName(gl); ! } } } *************** *** 2101,2128 **** } } } ! /** ! * Draw the frame of a clippingplane ! * @param clipplane The clippingplane */ ! private void drawClipplaneFrame(ClippingPlane clipplane) { { - Collection corners = clipplane.getCorners(); - gl.glColor3fv(CLIP_PLANE_COLOR); gl.glLineWidth(2.0f); ! gl.glBegin(GL.GL_LINE_STRIP); Iterator it = corners.iterator(); while (it.hasNext()) { Vertex v = (Vertex)it.next(); gl.glVertex3d(v.getX(), ! v.getY(), ! v.getZ()); } - Vertex v = (Vertex) corners.iterator().next(); - gl.glVertex3d(v.getX(), - v.getY(), - v.getZ()); gl.glEnd(); } } --- 2113,2153 ---- } } + enableClipplanes(); } ! /** ! * Draw a clippingPlane ! * @param clipplane The clipplane to draw */ ! private void drawClipplaneIntersection(ClippingPlane clipplane) { ! Collection corners = clipplane.getCorners(); { gl.glLineWidth(2.0f); ! pushName(gl, clipplane); ! gl.glBegin(GL.GL_LINE_LOOP); Iterator it = corners.iterator(); while (it.hasNext()) { Vertex v = (Vertex)it.next(); gl.glVertex3d(v.getX(), ! v.getY(), ! v.getZ()); } gl.glEnd(); + popName(gl); + } + if (clipplane.isActive()) { + Collection lines = clipplane.getLines(); + Iterator it = lines.iterator(); + while (it.hasNext()) { + Edge e = (Edge)it.next(); + Geometric g = clipplane.toModel(e); + pushName(gl, g); + if (e.getStrippled()) { + drawConstructor(e); + } else { + drawEdge(e); + } + popName(gl); + } } } *************** *** 2132,2136 **** * @param clipplane The clipplane to draw */ ! private void drawClipplane(ClippingPlane clipplane) { Collection corners = clipplane.getCorners(); { --- 2157,2161 ---- * @param clipplane The clipplane to draw */ ! private void drawClipplane(ClippingPlane clipplane) { Collection corners = clipplane.getCorners(); { *************** *** 2141,2163 **** Vertex v = (Vertex)it.next(); gl.glVertex3d(v.getX(), ! v.getY(), ! v.getZ()); } gl.glEnd(); } ! Collection lines = clipplane.getLines(); ! Iterator it = lines.iterator(); ! if (clipplane.getClipdepth() == 0) { ! while (it.hasNext()) { ! Edge e = (Edge)it.next(); ! drawConstructor(e); ! } ! } else { while (it.hasNext()) { Edge e = (Edge)it.next(); ! drawEdge(e); } } - } --- 2166,2186 ---- Vertex v = (Vertex)it.next(); gl.glVertex3d(v.getX(), ! v.getY(), ! v.getZ()); } gl.glEnd(); } ! if (clipplane.isActive()) { ! Collection lines = clipplane.getLines(); ! Iterator it = lines.iterator(); while (it.hasNext()) { Edge e = (Edge)it.next(); ! if (e.getStrippled()) { ! drawConstructor(e); ! } else { ! drawEdge(e); ! } } } } *************** *** 2478,2482 **** // If an construction edge is hit, see if there is a real edge // coincident with the construction-edge. - if (edge != null) { edges.remove(edge); --- 2501,2504 ---- *************** *** 2495,2499 **** } } - if (intersections) { Transformation transformation = this.transformation(); --- 2517,2520 ---- *************** *** 2575,2578 **** --- 2596,2606 ---- Vertex intersection = plane.intersection(ray); return new Intersection(intersection, Intersection.SURFACE, surface); + } else if (object instanceof ClippingPlane) { + // find out what is intersected + Plane p = ((ClippingPlane)object).getPlane(); + Vertex intersection = p.intersection(ray); + if (intersection != null) { + return new Intersection(intersection, Intersection.PLANE_INTERSECTION, xy); + } } else { Vertex intersection = xy.intersection(ray); |