/// <summary> /// Move the node by specified amount. /// </summary> /// <param name="node"></param> /// <param name="delta"></param> private void MoveNode(WayPoint.Node node, Vector3 delta) { node.Translate(delta); Changed(); }
/// <summary> /// Drag the current node/edge/path by mouse movement. Includes raise/lower /// as well as horizontal drag. /// </summary> /// <param name="camera"></param> private void DoDrag(Camera camera) { Vector2 pos = Vector2.Zero; Vector2 prevPos = Vector2.Zero; TouchContact touch = TouchInput.GetOldestTouch(); if (touch != null) { pos = touch.position; prevPos = touch.previousPosition; } Vector3 newPosition = Vector3.Zero; if (mode == Mode.Drag) { newPosition = TouchEdit.FindAtHeight(camera, TouchInput.GetAsPoint(TouchGestureManager.Get().DragGesture.DragPosition), height); } Vector3 delta = Vector3.Zero; if (mode == Mode.Raise) { float dheight = MouseInput.Position.Y - MouseInput.PrevPosition.Y; float kUpDownSpeed = -0.002f; dheight *= kUpDownSpeed; Vector3 dragPos = camera.ActualFrom; bool asRoad = false; if (node != null) { dragPos = node.RenderPosition(asRoad); } if (edge != null) { dragPos = (edge.Node0.RenderPosition(asRoad) + edge.Node1.RenderPosition(asRoad)) * 0.5f; } float dist = Vector3.Distance(dragPos, camera.ActualFrom); dheight *= dist; delta.Z = dheight; } if (newPosition != Vector3.Zero && Path != null) { if (actOnPath) { if (node != null) { Path.Translate(newPosition - node.Position); } else if (edge != null) { Path.Translate(newPosition - edge.HandlePosition); } } else if (node != null) { node.Translate(newPosition - node.Position); } else if (edge != null) { edge.Translate(newPosition - edge.HandlePosition); } skeletonTimer = kSkeletonTime; } if ((delta != Vector3.Zero) && (Path != null)) { if (actOnPath) { MovePath(Path, delta); } else if (node != null) { MoveNode(node, delta); } else if (edge != null) { MoveEdge(edge, delta); } skeletonTimer = kSkeletonTime; } }