예제 #1
0
                /// <summary>
                /// Find the correct position to add a node.
                /// </summary>
                /// <param name="camera"></param>
                /// <param name="from"></param>
                /// <returns></returns>
                private Vector3 AddPosition(Camera camera, WayPoint.Node from)
                {
                    bool  asRoad = false;
                    float height = from.RenderPosition(asRoad).Z;

                    Vector3 hit = MouseEdit.FindAtHeight(camera, MouseInput.Position, height);

                    return(hit);
                }
예제 #2
0
                /// <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)
                {
                    Vector3 delta = Vector3.Zero;

                    if (mode == Mode.Drag)
                    {
                        Vector3 oldPos = MouseEdit.FindAtHeight(camera, MouseInput.PrevPosition, height);
                        Vector3 newPos = MouseEdit.FindAtHeight(camera, MouseInput.Position, height);

                        delta = newPos - oldPos;
                    }

                    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 ((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;
                    }
                }