[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool ExtrusionTool.java,1.30,1.31
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2005-11-23 16:52:05
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21272 Modified Files: ExtrusionTool.java Log Message: simplified moving the extrusion by using the surface move method. Improved extruding into other surfaces however still only works when extruding into surfaces that are parrallel with the original surface Index: ExtrusionTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ExtrusionTool.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** ExtrusionTool.java 23 Nov 2005 13:18:23 -0000 1.30 --- ExtrusionTool.java 23 Nov 2005 16:51:56 -0000 1.31 *************** *** 69,72 **** --- 69,75 ---- private String number; + /** Wherther we are still allowed to drag the extrusion */ + private boolean dragAllowed; + /** * The Constructor *************** *** 88,104 **** return; } ! if (target instanceof Surface) { ! Surface selectedSurface = (Surface)target; ! if (dragSurface == null) { ! dragSurface = createExtension(selectedSurface); ! } else { ! Vertex normal = dragSurface.normal(); ! normal.scale(1 / normal.length()); ! View view = glv.getView(); ! Vertex from = view.toPlaneCoords(new double[] {prevX, prevY}, dragplane); ! Vertex to = view.toPlaneCoords(new double[] {e.getX(), e.getY()}, dragplane); ! Vertex delta = to.minus(from); ! double normDotDelta = normal.dot(delta); ! moveDelta(normDotDelta); } } --- 91,109 ---- return; } ! if (dragAllowed) { ! if (target instanceof Surface) { ! Surface selectedSurface = (Surface)target; ! if (dragSurface == null) { ! dragSurface = createExtension(selectedSurface); ! } else { ! Vertex normal = dragSurface.normal(); ! normal.scale(1 / normal.length()); ! View view = glv.getView(); ! Vertex from = view.toPlaneCoords(new double[] {prevX, prevY}, dragplane); ! Vertex to = view.toPlaneCoords(new double[] {e.getX(), e.getY()}, dragplane); ! Vertex delta = to.minus(from); ! double normDotDelta = normal.dot(delta); ! moveDelta(normDotDelta); ! } } } *************** *** 115,165 **** normal.scale(1 / normal.length()); normal.scale(delta / (normal.length() * normal.length())); ! List l = dragSurface.getVertices(); ! //moving the dragged surface along its normal vector ! for (int count = 0; l != null && count < l.size() - 1; count++) { ! Vertex v = (Vertex)l.get(count); ! updateVertex(v, new double[] {v.getX() + normal.getX(), ! v.getY() + normal.getY(), ! v.getZ() + normal.getZ()}); ! } ! //also moving any inner surfaces ! Set innerSurfaces = dragSurface.getInnerSurfaces(); ! if (innerSurfaces != null) { ! Iterator innerIt = innerSurfaces.iterator(); ! while (innerIt.hasNext()) { ! Surface innerSurf = (Surface)innerIt.next(); ! List verticies = innerSurf.getVertices(); ! for (int count = 0; verticies != null && count < verticies.size() - 1; count++) { ! Vertex v = (Vertex)verticies.get(count); ! updateVertex(v, new double[] {v.getX() + normal.getX(), ! v.getY() + normal.getY(), ! v.getZ() + normal.getZ()}); ! } ! } ! } Surface inSurface = inOtherSurface(dragSurface); if (inSurface != null) { ! List list = dragSurface.getVertices(); ! Iterator listIt = list.iterator(); ! Vertex to = null; ! Vertex from = null; ! Vertex first = null; ! List edges = new LinkedList(); ! if (listIt.hasNext()) { ! from = (Vertex)listIt.next(); ! first = from; ! } ! while (listIt.hasNext()) { ! to = (Vertex)listIt.next(); ! edges.add(createEdge(from, to)); ! from = to; ! } ! if (from != null) { ! edges.add(createEdge(from, first)); ! } ! Surface hole = createSurface(edges); ! inSurface.addHole(hole); ! dragSurface = createExtension(dragSurface); ! spaceAssignment(); } if (extrusion != null) { --- 120,128 ---- normal.scale(1 / normal.length()); normal.scale(delta / (normal.length() * normal.length())); ! dragSurface.move(normal.getX(), normal.getY(), normal.getZ()); Surface inSurface = inOtherSurface(dragSurface); if (inSurface != null) { ! inSurface.addHole(dragSurface); ! endExtrusion(); } if (extrusion != null) { *************** *** 228,231 **** --- 191,204 ---- dragplane = selectedSurface.plane().orthogonalPlane(ray); } + dragAllowed = true; + } + + /** + * Does the work when ending the current extrusion + */ + private void endExtrusion() { + //holeDetection(); + spaceAssignment(); + dragAllowed = false; } *************** *** 236,241 **** protected void released(MouseEvent e) { super.released(e); ! //holeDetection(); ! spaceAssignment(); } --- 209,213 ---- protected void released(MouseEvent e) { super.released(e); ! endExtrusion(); } |