[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool ExtrusionTool.java,1.7,1.8
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2005-09-12 18:11:34
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30257 Modified Files: ExtrusionTool.java Log Message: Changed the way an extruded surface is moved to make more intuitive Index: ExtrusionTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ExtrusionTool.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ExtrusionTool.java 7 Sep 2005 11:30:34 -0000 1.7 --- ExtrusionTool.java 12 Sep 2005 18:11:26 -0000 1.8 *************** *** 62,132 **** if (target instanceof Surface) { Surface selectedSurface = (Surface)target; ! if (!selectedSurface.equals(dragSurface)) { if (isExtrudeable(selectedSurface)) { dragSurface = selectedSurface; } else { ! dragSurface = null; ! createExtension(selectedSurface); } ! } ! if (dragSurface != null) { ! if (viewType != View.VIEW_3D) { ! Vertex normal = dragSurface.normal(); ! if (normal != null) { ! double[] second = glv.getView().toCanvasCoords(new double[] {e.getX(), e.getY()}); ! normal.scale(1 / normal.length()); ! Vertex proj = dragSurface.projection(second); ! ! List l = Util.traverse(dragSurface); ! for (int count = 0; l != null && count < l.size(); count++) { ! Vertex v = (Vertex)l.get(count); ! updateVertex(v, new double[] {v.getX() + proj.getX(), ! v.getY() + proj.getY(), ! v.getZ() + proj.getZ()}); ! } ! } ! } else { ! Vertex normal = dragSurface.normal(); ! normal.scale(1 / normal.length()); ! View view = glv.getView(); ! double[] from = view.toPlaneCoords(new double[] {pressPos[0], pressPos[1]}, dragplane); ! double[] to = view.toPlaneCoords(new double[] {e.getX(), e.getY()}, dragplane); ! double[] delta = new double[] {to[0] - from[0], to[1] - from[1], to[2] - from[2]}; ! double normDotDelta = ((normal.getX() * delta[0]) + ! (normal.getY() * delta[1]) + ! (normal.getZ() * delta[2])); ! normal.scale(normDotDelta / (normal.length() * normal.length())); ! //normal.scale(delta); ! List l = Util.traverse(dragSurface); ! //moving the dragged surface along its normal vector ! for (int count = 0; l != null && count < l.size(); 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 = Util.traverse(innerSurf); ! for (int count = 0; verticies != null && count < verticies.size(); count++) { ! Vertex v = (Vertex)verticies.get(count); ! updateVertex(v, new double[] {v.getX() + normal.getX(), ! v.getY() + normal.getY(), ! v.getZ() + normal.getZ()}); ! } } } } } - pressPos[0] = e.getX(); - pressPos[1] = e.getY(); } } /** * Checks if a surface is extrudeable --- 62,115 ---- if (target instanceof Surface) { Surface selectedSurface = (Surface)target; ! if (dragSurface == null) { if (isExtrudeable(selectedSurface)) { dragSurface = selectedSurface; } else { ! log.info("IS NOT EXTRUDABLE!!!"); ! dragSurface = createExtension(selectedSurface); } ! } else { ! Vertex normal = dragSurface.normal(); ! normal.scale(1 / normal.length()); ! View view = glv.getView(); ! double[] from = view.toPlaneCoords(new double[] {pressPos[0], pressPos[1]}, dragplane); ! double[] to = view.toPlaneCoords(new double[] {e.getX(), e.getY()}, dragplane); ! double[] delta = new double[] {to[0] - from[0], to[1] - from[1], to[2] - from[2]}; ! double normDotDelta = ((normal.getX() * delta[0]) + ! (normal.getY() * delta[1]) + ! (normal.getZ() * delta[2])); ! normal.scale(normDotDelta / (normal.length() * normal.length())); ! //normal.scale(delta); ! List l = Util.traverse(dragSurface); ! //moving the dragged surface along its normal vector ! for (int count = 0; l != null && count < l.size(); 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 = Util.traverse(innerSurf); ! for (int count = 0; verticies != null && count < verticies.size(); count++) { ! Vertex v = (Vertex)verticies.get(count); ! updateVertex(v, new double[] {v.getX() + normal.getX(), ! v.getY() + normal.getY(), ! v.getZ() + normal.getZ()}); } } } } } + pressPos[0] = e.getX(); + pressPos[1] = e.getY(); } + /** * Checks if a surface is extrudeable *************** *** 177,192 **** int x = pressPos[0]; int y = pressPos[1]; ! Vertex near = new Vertex("near", 0.5, 0.5, 0.0); ! Vertex far = new Vertex("far", 0.5, 0.5, 1.0); Edge ray = new Edge("ray", near, far); ray = trans.unProject(ray); ! double[] norm = new double[] {(ray.getFrom().getX() - ray.getTo().getX()), ! (ray.getFrom().getY() - ray.getTo().getY()), ! (ray.getFrom().getZ() - ray.getTo().getZ())}; ! double[] clickPoint = view.toPlaneCoords(new double[] {x, y}, selectedSurface.plane()); ! dragplane = new Plane(norm[0], norm[1], norm[2], ! (-1 * (norm[0] * clickPoint[0] + ! norm[1] * clickPoint[1] + ! norm[2] * clickPoint[2]))); } } --- 160,168 ---- int x = pressPos[0]; int y = pressPos[1]; ! Vertex near = new Vertex("near", x, y, 0.0); ! Vertex far = new Vertex("far", x, y, 1.0); Edge ray = new Edge("ray", near, far); ray = trans.unProject(ray); ! dragplane = selectedSurface.plane().orthogonalPlane(ray); } } *************** *** 198,201 **** --- 174,178 ---- protected void released(MouseEvent e) { super.released(e); + dragSurface = null; } *************** *** 286,295 **** } ConstructionSpaceFacade.getInstance().create(newCSpace); ! dragSurface = createSurface(top); if (outer != null) { ! outer.addSurface(dragSurface); } ! newCSpace.addSurface(dragSurface); ! Notification n = new Notification(Notification.SURFACE_SELECTED, dragSurface.getId()); Notifier.getInstance().sendNotification(n); if (outer instanceof FunctionalSpace) { --- 263,272 ---- } ConstructionSpaceFacade.getInstance().create(newCSpace); ! Surface topSurf = createSurface(top); if (outer != null) { ! outer.addSurface(topSurf); } ! newCSpace.addSurface(topSurf); ! Notification n = new Notification(Notification.SURFACE_SELECTED, topSurf.getId()); Notifier.getInstance().sendNotification(n); if (outer instanceof FunctionalSpace) { *************** *** 302,313 **** Notifier.getInstance().sendNotification(n); ! return dragSurface; } /** ! * Do all the initial extrusion stuff * @param selectedSurface the surface to create extension to */ ! private void createExtension(Surface selectedSurface) { Surface top = extendSurface(selectedSurface); Set innerSurfaces = selectedSurface.getInnerSurfaces(); --- 279,291 ---- Notifier.getInstance().sendNotification(n); ! return topSurf; } /** ! * Do all the initial extrusion stuff returns the top of the extension * @param selectedSurface the surface to create extension to + * @return the top of the extension */ ! private Surface createExtension(Surface selectedSurface) { Surface top = extendSurface(selectedSurface); Set innerSurfaces = selectedSurface.getInnerSurfaces(); *************** *** 321,325 **** } } ! dragSurface = top; } } --- 299,303 ---- } } ! return top; } } |