[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool EdgeMoveTool.java, 1.1, 1.2 AbstractP
Status: Pre-Alpha
Brought to you by:
henryml
|
From: rimestad <rim...@us...> - 2007-03-23 15:27:30
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19250/src/net/sourceforge/bprocessor/gl/tool Modified Files: EdgeMoveTool.java AbstractPencil.java Log Message: made a working implementation of the edgemoveTool, there are some problems still but i works in some sense... The movement gets weird when for example two planes gets planar then the edge placement isn't unique and that gives som weird lacking movement, but otherwise I think it looks ok Index: EdgeMoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/EdgeMoveTool.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EdgeMoveTool.java 22 Mar 2007 11:47:06 -0000 1.1 --- EdgeMoveTool.java 23 Mar 2007 15:27:23 -0000 1.2 *************** *** 12,15 **** --- 12,16 ---- import java.util.Collection; import java.util.HashMap; + import java.util.HashSet; import java.util.LinkedList; import java.util.List; *************** *** 44,48 **** private HashMap<Surface, CoordinateSystem> coordMap; private HashMap<Surface, Line> swiwel; ! private Intersection previous; /** --- 45,50 ---- private HashMap<Surface, CoordinateSystem> coordMap; private HashMap<Surface, Line> swiwel; ! private Vertex initialFrom; ! private Vertex initialTo; /** *************** *** 56,72 **** ! private void move(Vertex to, Vertex from) { if (to == null) { ! System.out.println("move-to null"); } else { for (Surface surface : coordMap.keySet()) { CoordinateSystem system = coordMap.get(surface); ! Vertex about = swiwel.get(surface).getOrigin(); Vertex v1 = to.minus(about); ! Vertex v2 = from.minus(about); ! double angle = v1.dot(v2); ! System.out.println("Angle were " + angle); ! ! system.rotate(angle, swiwel.get(surface)); for (Vertex vertex : verticesMap.get(surface)) { --- 58,76 ---- ! private void move(Vertex to) { if (to == null) { ! System.out.println("move-to or move-from null"); } else { for (Surface surface : coordMap.keySet()) { CoordinateSystem system = coordMap.get(surface); ! Line l = swiwel.get(surface); ! Vertex about = l.getOrigin(); Vertex v1 = to.minus(about); ! v1.normalize(); ! Vertex j = l.getDirection(); ! Vertex n = j.cross(v1); ! v1 = n.cross(j); ! system.setIJN(v1, j, n); ! system.setOrigin(about); for (Vertex vertex : verticesMap.get(surface)) { *************** *** 83,100 **** system.update(); } - /* - system.setOrigin(to); - for (Vertex vertex : vertices) { - Vertex vector = system.getN(); - Collection<Edge> binding = map.get(vertex); - if (!binding.isEmpty()) { - Edge bind = binding.iterator().next(); - vector = bind.getDirection(); - vector.normalize(); - } - Vertex project = system.slide(vertex, vector); - vertex.set(project); - } - system.update();*/ } } --- 87,90 ---- *************** *** 109,121 **** } else { Vertex hit = glv.getView().toPlaneCoords(e.getX(), e.getY(), dragplane); ! previous = current; ! current = new Intersection(hit, Intersection.EDGE, null); Vertex from = start.vertex(); ! makeTarget(current); Vertex to = current.vertex(); Edge edge = new Edge(from, to); edge.setStrippled(true); edges.add(edge); ! move(to, previous.vertex()); } feedback(edges); --- 99,110 ---- } else { Vertex hit = glv.getView().toPlaneCoords(e.getX(), e.getY(), dragplane); ! current = new Intersection(hit, Intersection.EDGE, edge); Vertex from = start.vertex(); ! makeTarget(start); Vertex to = current.vertex(); Edge edge = new Edge(from, to); edge.setStrippled(true); edges.add(edge); ! move(to); } feedback(edges); *************** *** 130,133 **** --- 119,124 ---- if (target instanceof Edge) { edge = (Edge) target; + initialFrom = edge.getFrom().copy(); + initialTo = edge.getTo().copy(); Set<Surface> surfaces = edge.getSurfaces(); verticesMap = new HashMap<Surface, Collection<Vertex>>(); *************** *** 149,154 **** Vertex center = surface.oppositeVertex(edge); swiwel.put(surface, new Line(center, edge.getDirection())); ! ! verticesMap.put(surface, surface.getVertices()); } --- 140,146 ---- Vertex center = surface.oppositeVertex(edge); swiwel.put(surface, new Line(center, edge.getDirection())); ! Set<Vertex> verts = new HashSet<Vertex>(); ! Geometry.collect(surface, verts); ! verticesMap.put(surface, verts); } *************** *** 158,168 **** if (!coordMap.containsKey(surface)) { CoordinateSystem system = surface.coordinateSystem(); ! system.onlyPlane(true); system.setActive(true); coordMap.put(surface, system); } } } start = findIntersection(e); makeTarget(start); for (CoordinateSystem cs : coordMap.values()) { --- 150,163 ---- if (!coordMap.containsKey(surface)) { CoordinateSystem system = surface.coordinateSystem(); ! system.onlyPlane(false); system.setActive(true); coordMap.put(surface, system); } } + } else { + return; } start = findIntersection(e); + current = start; makeTarget(start); for (CoordinateSystem cs : coordMap.values()) { *************** *** 177,186 **** Edge ray = new Edge(near, far); ray = trans.unProject(ray); ! Vertex dir = edge.getDirection(); ! Plane plane = new Plane(dir.getX(), dir.getY(), dir.getZ(), start.vertex()); ! dragplane = plane.orthogonalPlane(ray); ! } else { Project.getInstance().checkpoint(); cleanUp(); moved(e); --- 172,182 ---- Edge ray = new Edge(near, far); ray = trans.unProject(ray); ! Vertex norm = ray.getDirection(); ! norm.normalize(); ! norm.scale(-1); ! dragplane = new Plane(norm.getX(), norm.getY(), norm.getZ(), start.vertex()); } else { Project.getInstance().checkpoint(); + start = null; cleanUp(); moved(e); *************** *** 192,196 **** public void cleanUp() { if (start != null) { ! move(current.vertex(), start.vertex()); } if (coordMap != null) { --- 188,194 ---- public void cleanUp() { if (start != null) { ! move(start.vertex()); ! edge.getTo().set(initialTo); ! edge.getFrom().set(initialFrom); } if (coordMap != null) { Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** AbstractPencil.java 6 Feb 2007 17:28:26 -0000 1.73 --- AbstractPencil.java 23 Mar 2007 15:27:23 -0000 1.74 *************** *** 604,608 **** case Intersection.EDGE: Edge edge = (Edge) intersection.object(); ! if (edge.getStrippled()) { target = current; targetColor = View.EDGE_ON_COLOR; --- 604,608 ---- case Intersection.EDGE: Edge edge = (Edge) intersection.object(); ! if (edge != null && edge.getStrippled()) { target = current; targetColor = View.EDGE_ON_COLOR; |