[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool AbstractPencil.java, 1.82, 1.83
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2007-06-26 00:40:37
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv24124/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractPencil.java Log Message: Improved snap-feedback when locked and did some clean up. Still need to do feedback to show was is locked to. Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** AbstractPencil.java 25 Jun 2007 21:41:55 -0000 1.82 --- AbstractPencil.java 26 Jun 2007 00:40:11 -0000 1.83 *************** *** 38,42 **** import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; - import net.sourceforge.bprocessor.model.Camera; import org.apache.log4j.Logger; --- 38,41 ---- *************** *** 101,104 **** --- 100,106 ---- protected Plane lockingPlane; + /** Vertex snapped to when locking */ + protected Vertex lockSnapVertex; + /** Original vertex when snapping */ protected Vertex original; *************** *** 199,202 **** --- 201,207 ---- unwanted.addAll(elements); unwanted.addAll(excluded); + if (lockSnapVertex != null) { + unwanted.add(lockSnapVertex); + } intersection = (Intersection) glv.getView().getObjectAtPoint(e.getX(), e.getY(), *************** *** 214,218 **** v = intersection.vertex(); if (v.getOwner() != space) { ! Set vertices = space.findByLocation(v.getX(), v.getY(), v.getZ(), 0.0000001); if (!vertices.isEmpty()) { v = (Vertex) vertices.iterator().next(); --- 219,223 ---- v = intersection.vertex(); if (v.getOwner() != space) { ! Set vertices = space.findByLocation(v.getX(), v.getY(), v.getZ(), Geometry.EPS); if (!vertices.isEmpty()) { v = (Vertex) vertices.iterator().next(); *************** *** 226,230 **** if (lockingEdge != null) { Vertex vertex = lockingEdge.intersection(intersection.vertex()); ! intersection = new Intersection(vertex, Intersection.EDGE, lockingEdge); } --- 231,237 ---- if (lockingEdge != null) { Vertex vertex = lockingEdge.intersection(intersection.vertex()); ! intersection = new Intersection(vertex, ! Intersection.LOCK_INTERSECTION, ! intersection); } *************** *** 232,236 **** if (!lockingPlane.contains(intersection.vertex())) { Vertex vertex = lockingPlane.projection(intersection.vertex()); ! intersection = new Intersection(vertex, Intersection.PLANE_INTERSECTION, lockingPlane); } } --- 239,245 ---- if (!lockingPlane.contains(intersection.vertex())) { Vertex vertex = lockingPlane.projection(intersection.vertex()); ! intersection = new Intersection(vertex, ! Intersection.LOCK_INTERSECTION, ! intersection); } } *************** *** 398,402 **** */ protected List computeConstructors() { ! List constructors = new LinkedList(); if (start != null) { constructors.add(new CoordinateSystem(start.vertex().copy())); --- 407,411 ---- */ protected List computeConstructors() { ! List<Constructor> constructors = new LinkedList<Constructor>(); if (start != null) { constructors.add(new CoordinateSystem(start.vertex().copy())); *************** *** 451,455 **** Line orthogonal = null; ! if (Math.abs(direction.getZ()) < 0.0000001) { if (start != null) { orthogonal = new Line(start.vertex(), direction, true, false); --- 460,464 ---- Line orthogonal = null; ! if (Math.abs(direction.getZ()) < Geometry.EPS) { if (start != null) { orthogonal = new Line(start.vertex(), direction, true, false); *************** *** 495,533 **** excluded.addAll(feed); } - - /** - * Get the plane out of the XY XZ and YZ planes that is best aligned - * with screen. - * @return the plane - */ - protected Plane bestAlignedPlane() { - Camera camera = Project.getInstance().getCurrentCamera(); - double[] centerPoint = camera.getCenter(); - double[] cameraPoint = camera.getCamera(); - - Vertex eyeVector = new Vertex(cameraPoint[0] - centerPoint[0], - cameraPoint[1] - centerPoint[1], - cameraPoint[2] - centerPoint[2]); - eyeVector.scale(1 / eyeVector.length()); - - Vertex normal; - Vertex xyNormal = new Vertex(0, 0, 1); - Vertex xzNormal = new Vertex(0, 1, 0); - Vertex yzNormal = new Vertex(1, 0, 0); - if (Math.abs(eyeVector.dot(xyNormal)) > - Math.abs(eyeVector.dot(xzNormal))) { - normal = xyNormal; - } else { - normal = xzNormal; - } - if (Math.abs(eyeVector.dot(yzNormal)) > - Math.abs(eyeVector.dot(normal))) { - normal = yzNormal; - } - return new Plane(normal.getX(), - normal.getY(), - normal.getZ(), 0); - } - /** --- 504,507 ---- *************** *** 593,622 **** timer.restart(); if (intersection != null) { ! float[] targetColor = View.TARGET_COLOR; ! Vertex current = intersection.vertex(); ! target = current; ! switch (intersection.type()) { ! case Intersection.EDGE: ! targetColor = View.EDGE_ON_COLOR; ! break; ! case Intersection.SURFACE: ! targetColor = View.SURFACE_ON_COLOR; ! break; ! case Intersection.EDGE_MIDPOINT: ! targetColor = View.EDGE_INTERSECTION_COLOR; ! break; ! case Intersection.EDGE_INTERSECTION: ! targetColor = View.EDGE_INTERSECTION_COLOR; ! break; ! case Intersection.SURFACE_INTERSECTION: ! targetColor = View.EDGE_INTERSECTION_COLOR; ! break; ! case Intersection.PLANE_INTERSECTION: target = null; ! break; } glv.getView().makeTarget(target, targetColor); } } /** --- 567,616 ---- timer.restart(); if (intersection != null) { ! Intersection actual = intersection; ! target = intersection.vertex(); ! float[] targetColor = targetColor(intersection); ! glv.getView().removeTempVertex(lockSnapVertex); ! glv.getView().clearColor(lockSnapVertex); ! if (intersection.type() == Intersection.LOCK_INTERSECTION) { ! actual = (Intersection)actual.object(); ! lockSnapVertex = actual.vertex(); ! targetColor = targetColor(actual); ! glv.getView().addTempVertex(lockSnapVertex); ! glv.getView().changeColor(lockSnapVertex, targetColor); ! } ! if (actual.type() == Intersection.PLANE_INTERSECTION) { target = null; ! glv.getView().removeTempVertex(lockSnapVertex); ! glv.getView().clearColor(lockSnapVertex); } glv.getView().makeTarget(target, targetColor); } } + + /** + * @param intersection + * @return + */ + private float[] targetColor(Intersection intersection) { + float[] targetColor = View.TARGET_COLOR; + switch (intersection.type()) { + case Intersection.EDGE: + targetColor = View.EDGE_ON_COLOR; + break; + case Intersection.SURFACE: + targetColor = View.SURFACE_ON_COLOR; + break; + case Intersection.EDGE_MIDPOINT: + targetColor = View.EDGE_INTERSECTION_COLOR; + break; + case Intersection.EDGE_INTERSECTION: + targetColor = View.EDGE_INTERSECTION_COLOR; + break; + case Intersection.SURFACE_INTERSECTION: + targetColor = View.EDGE_INTERSECTION_COLOR; + break; + } + return targetColor; + } /** *************** *** 661,665 **** if (before != null) { Vertex v = current.vertex().minus(before); ! if (v.length() > 0.000000001) { v.scale(length / v.length()); Vertex to = before.add(v); --- 655,659 ---- if (before != null) { Vertex v = current.vertex().minus(before); ! if (v.length() > Geometry.EPS) { v.scale(length / v.length()); Vertex to = before.add(v); |