Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool MoveTool.java,1.39,1.40
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2006-02-23 16:04:28
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7278/tool Modified Files: MoveTool.java Log Message: controlled move of surfaces and vertices aswell Index: MoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/MoveTool.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** MoveTool.java 17 Feb 2006 09:57:24 -0000 1.39 --- MoveTool.java 23 Feb 2006 16:04:13 -0000 1.40 *************** *** 106,111 **** private HashMap slideMap; ! /** The edge being moved in a controlled way */ ! private Edge controlled; /** --- 106,111 ---- private HashMap slideMap; ! /** The entity being moved in a controlled way */ ! private Entity controlled; /** *************** *** 158,164 **** if (target != null) { if (moveMode != THREE_CLICK) { - //super.pressed(e); initial = findInitial(target, e); from = initial.copy(); setupConstructors(); --- 158,164 ---- if (target != null) { if (moveMode != THREE_CLICK) { initial = findInitial(target, e); from = initial.copy(); + slideMap = new HashMap(); setupConstructors(); *************** *** 167,178 **** vertices = new HashSet(); moveEntities = selection; - collect(selection, vertices); if (moveMode == CONTROLLED) { ! if (target instanceof Edge) { ! controlled = (Edge)target; ! } else { ! log.warn("Controlled move only works with edges"); } } } else { threeClickMove(e); --- 167,179 ---- vertices = new HashSet(); moveEntities = selection; if (moveMode == CONTROLLED) { ! if (!selection.isEmpty()) { ! Iterator it = selection.iterator(); ! controlled = (Entity)it.next(); } + selection = new HashSet(); + selection.add(controlled); } + collect(selection, vertices); } else { threeClickMove(e); *************** *** 433,487 **** if (toSlideEdge == null && fromSlideEdge == null) { findTarget(e); ! if (target instanceof Surface) { ! Surface targetSurface = (Surface)target; ! if (controlled.getSurfaces().contains(targetSurface)) { ! glv.getView().makeTarget(target); ! dragPlane = targetSurface.plane(); ! Vertex controlledDir = controlled.getDirection(); ! Vertex surfaceNormal = targetSurface.normal(); ! restrictionVector = controlledDir.cross(surfaceNormal); ! restrictionVector.scale(1 / restrictionVector.length()); ! ! List edges = targetSurface.getEdges(); ! int index = edges.indexOf(controlled); ! Edge leftEdge; ! Edge rightEdge; ! if (index == 0) { ! leftEdge = (Edge)edges.get(edges.size() - 1); ! rightEdge = (Edge)edges.get(index + 1); ! } else if (index == (edges.size() - 1)) { ! leftEdge = (Edge)edges.get(index - 1); ! rightEdge = (Edge)edges.get(0); ! } else { ! leftEdge = (Edge)edges.get(index - 1); ! rightEdge = (Edge)edges.get(index + 1); } ! if (controlledDir.cross(leftEdge.getDirection()).length() > 0.00001 && ! controlledDir.cross(rightEdge.getDirection()).length() > 0.00001) { ! Vertex to = controlled.getTo(); ! Vertex from = controlled.getFrom(); ! if (to.getEdges().contains(leftEdge) && ! from.getEdges().contains(rightEdge)) { ! toSlideEdge = leftEdge; ! fromSlideEdge = rightEdge; ! } else if (from.getEdges().contains(leftEdge) && ! to.getEdges().contains(rightEdge)) { ! fromSlideEdge = leftEdge; ! toSlideEdge = rightEdge; } ! slideMap = new HashMap(); ! slideMap.put(controlled.getTo(), toSlideEdge.getDirection()); ! slideMap.put(controlled.getFrom(), fromSlideEdge.getDirection()); ! } else { ! dragPlane = null; ! restrictionVector = null; ! log.warn("This edge is bound"); } } } } } } ! /** * Creates the surface spanned by two edges connected --- 434,532 ---- if (toSlideEdge == null && fromSlideEdge == null) { findTarget(e); ! if (controlled instanceof Edge) { ! Edge controlledEdge = (Edge)controlled; ! if (target instanceof Surface) { ! Surface targetSurface = (Surface)target; ! if (controlledEdge.getSurfaces().contains(targetSurface)) { ! glv.getView().makeTarget(target); ! dragPlane = targetSurface.plane(); ! Vertex controlledDir = controlledEdge.getDirection(); ! Vertex surfaceNormal = targetSurface.normal(); ! restrictionVector = controlledDir.cross(surfaceNormal); ! restrictionVector.scale(1 / restrictionVector.length()); ! ! List edges = targetSurface.getEdges(); ! int index = edges.indexOf(controlledEdge); ! Edge leftEdge; ! Edge rightEdge; ! if (index == 0) { ! leftEdge = (Edge)edges.get(edges.size() - 1); ! rightEdge = (Edge)edges.get(index + 1); ! } else if (index == (edges.size() - 1)) { ! leftEdge = (Edge)edges.get(index - 1); ! rightEdge = (Edge)edges.get(0); ! } else { ! leftEdge = (Edge)edges.get(index - 1); ! rightEdge = (Edge)edges.get(index + 1); ! } ! if (controlledDir.cross(leftEdge.getDirection()).length() > 0.00001 && ! controlledDir.cross(rightEdge.getDirection()).length() > 0.00001) { ! Vertex to = controlledEdge.getTo(); ! Vertex from = controlledEdge.getFrom(); ! if (to.getEdges().contains(leftEdge) && ! from.getEdges().contains(rightEdge)) { ! toSlideEdge = leftEdge; ! fromSlideEdge = rightEdge; ! } else if (from.getEdges().contains(leftEdge) && ! to.getEdges().contains(rightEdge)) { ! fromSlideEdge = leftEdge; ! toSlideEdge = rightEdge; ! } ! slideMap = new HashMap(); ! slideMap.put(controlledEdge.getTo(), toSlideEdge.getDirection()); ! slideMap.put(controlledEdge.getFrom(), fromSlideEdge.getDirection()); ! } else { ! dragPlane = null; ! restrictionVector = null; ! log.warn("This edge is bound"); ! } } ! } ! } else if (controlled instanceof Vertex) { ! Vertex controlledVertex = (Vertex)controlled; ! if (target instanceof Edge && ! controlledVertex.getEdges().contains((Edge)target)) { ! Edge targetEdge = (Edge)target; ! slideMap = new HashMap(); ! slideMap.put(controlledVertex, targetEdge.getDirection()); ! restrictionVector = targetEdge.getDirection(); ! findRestrictionPlane(); ! fromSlideEdge = targetEdge; ! toSlideEdge = targetEdge; ! } ! } else if (controlled instanceof Surface) { ! Surface controlledSurface = (Surface)controlled; ! restrictionVector = controlledSurface.normal(); ! findRestrictionPlane(); ! slideMap = new HashMap(); ! Collection vertices = controlledSurface.getVertices(); ! Iterator it = vertices.iterator(); ! boolean bound = false; ! while (it.hasNext() && !bound) { ! Vertex vertex = (Vertex)it.next(); ! slideMap.put(vertex, restrictionVector); ! Collection edges = vertex.getEdges(); ! Iterator edgeIt = edges.iterator(); ! int otherEdges = 0; ! while (edgeIt.hasNext() && !bound) { ! Edge edge = (Edge)edgeIt.next(); ! if (!controlledSurface.getEdges().contains(edge)) { ! otherEdges++; ! slideMap.put(vertex, edge.getDirection()); } ! bound = otherEdges > 1; } } + if (bound) { + slideMap = new HashMap(); + restrictionVector = null; + dragPlane = null; + log.warn("this surface is bound!"); + } } } } } ! /** * Creates the surface spanned by two edges connected *************** *** 627,630 **** --- 672,684 ---- Vertex slideDir = (Vertex)slideMap.get(vertex); double slideScale; + if (delta == null) { + log.info("delta null"); + } + if (slideDir == null) { + log.info("slideDir null"); + } + if (deltaUnit == null) { + log.info("deltaUnit null"); + } if (delta.getX() != 0) { slideScale = delta.getX() / (slideDir.dot(deltaUnit) * deltaUnit.getX()); |