Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool ControlledExtrudeTool.java, 1.4, 1.5
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-09-28 14:08:25
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv22960/src/net/sourceforge/bprocessor/gl/tool Modified Files: ControlledExtrudeTool.java Log Message: Minor changes to controlled extrude Index: ControlledExtrudeTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ControlledExtrudeTool.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ControlledExtrudeTool.java 27 Sep 2007 12:20:22 -0000 1.4 --- ControlledExtrudeTool.java 28 Sep 2007 14:08:21 -0000 1.5 *************** *** 77,94 **** @Override protected void moved(MouseEvent e) { findTarget(e, View.HANDLES); if (pressedSurface == null) { if (target instanceof Surface) { glv.getView().makeTarget(target); } } else { ! double x = e.getX(); ! double y = View.getHeight() - e.getY(); ! ! Vertex near = new Vertex(x, y, 0.0); ! Vertex far = new Vertex(x, y, 1.0); ! Edge ray = new Edge(near, far); ! Transformation transformation = glv.getView().transformation(); ! ray = transformation.unProject(ray); Vertex hit = dragPlane.intersection(ray); current = new Intersection(hit.minus(start.vertex()).projectOnto(normal).add(start.vertex()), --- 77,99 ---- @Override protected void moved(MouseEvent e) { + glv.getView().makeTarget(null); findTarget(e, View.HANDLES); + double x = e.getX(); + double y = View.getHeight() - e.getY(); + Vertex near = new Vertex(x, y, 0.0); + Vertex far = new Vertex(x, y, 1.0); + Edge ray = new Edge(near, far); + Transformation transformation = glv.getView().transformation(); + ray = transformation.unProject(ray); + if (pressedSurface == null) { + // If the extrusion havn't started yet if (target instanceof Surface) { glv.getView().makeTarget(target); + current = new Intersection(((Surface)target).intersection(ray), + Intersection.SURFACE, target); } } else { ! // The extrusion is started Vertex hit = dragPlane.intersection(ray); current = new Intersection(hit.minus(start.vertex()).projectOnto(normal).add(start.vertex()), *************** *** 97,103 **** Plane p = null; if (target instanceof Surface && !affected.contains(target)) { ! p = ((Surface)target).plane(); ! if (Math.abs((Math.abs(p.normal().angle(normal)) - Math.PI / 2)) < 0.01) { ! p = null; } } --- 102,108 ---- Plane p = null; if (target instanceof Surface && !affected.contains(target)) { ! Surface s = (Surface)target; ! if (Math.abs((Math.abs(s.normal().angle(normal)) - Math.PI / 2)) >= 0.05) { ! p = new Plane(normal.projectOnto(s.normal()), s.getFirstVertex()); } } *************** *** 107,111 **** if (v2dir.isEmpty()) { ! // If the extrusion isn't started start it Vertex delta = current.vertex().minus(start.vertex()); double length = delta.length(); --- 112,116 ---- if (v2dir.isEmpty()) { ! // If the extrusion isn't generated generate it Vertex delta = current.vertex().minus(start.vertex()); double length = delta.length(); *************** *** 114,121 **** } - Collection feed = new ArrayList(); - feed.add(new Edge(start.vertex(), start.vertex().add(normal))); - feedback(feed); - Surface topSurface = pressedSurface.extrusionControlled(length, extrusion, v2dir); if (topSurface != pressedSurface) { --- 119,122 ---- *************** *** 139,143 **** } } else { ! //there is a extrusion move it to the apropiate location extrudeTo(p); } --- 140,144 ---- } } else { ! //the extrusion is generated move it to the correct location extrudeTo(p); } *************** *** 147,162 **** private void extrudeTo(Plane p) { double dist = p.distance(start.vertex()) * -1; ! if (dist <= minExtrude) { p.moveDelta(dist - minExtrude); } ! if (dist >= maxExtrude) { p.moveDelta(dist - maxExtrude); } ! current.vertex().set(p.intersection(start.vertex(), normal, true)); for (Vertex v : v2dir.keySet()) { Direction d = v2dir.get(v); Vertex intersection = p.intersection(d.getVertex(), d.getDirection(), true); ! d.getVertex().set(intersection); } updateLength(); --- 148,169 ---- private void extrudeTo(Plane p) { double dist = p.distance(start.vertex()) * -1; ! if (dist < minExtrude) { p.moveDelta(dist - minExtrude); } ! if (dist > maxExtrude) { p.moveDelta(dist - maxExtrude); } ! if (dist != 0) { ! current.vertex().set(p.intersection(start.vertex(), normal, true)); ! } else { ! current.vertex().set(start.vertex()); ! } for (Vertex v : v2dir.keySet()) { Direction d = v2dir.get(v); Vertex intersection = p.intersection(d.getVertex(), d.getDirection(), true); ! if (intersection != null) { ! d.getVertex().set(intersection); ! } } updateLength(); *************** *** 166,170 **** @Override protected void pressed(MouseEvent e) { ! current = findIntersection(e); if (v2dir.isEmpty() && target != null && target instanceof Surface) { active = true; --- 173,177 ---- @Override protected void pressed(MouseEvent e) { ! //current = findIntersection(e); if (v2dir.isEmpty() && target != null && target instanceof Surface) { active = true; *************** *** 194,198 **** Space owner = Project.getInstance().getActiveSpace(); owner.removeProtected(extrusion); ! if (pressedSurface != null && !start.vertex().minus(current.vertex()).isZero()) { excluded(new ArrayList()); Mesh m = new Mesh(extrusion); --- 201,206 ---- Space owner = Project.getInstance().getActiveSpace(); owner.removeProtected(extrusion); ! if (pressedSurface != null && ! !start.vertex().minus(current.vertex()).projectOnto(normal).isZero()) { excluded(new ArrayList()); Mesh m = new Mesh(extrusion); *************** *** 220,225 **** public void escape() { if (pressedSurface != null) { ! extrudeTo(new Plane(normal.getX(), normal.getY(), normal.getZ(), start.vertex())); ! Project.getInstance().getActiveSpace().removeProtected(extrusion); } cleanUp(); --- 228,232 ---- public void escape() { if (pressedSurface != null) { ! Project.getInstance().resetState(); } cleanUp(); *************** *** 234,237 **** --- 241,245 ---- v2dir.clear(); pressedSurface = null; + dragPlane = null; normal = null; active = false; |