Пример #1
0
        private LinearMath.Vector ScreenToWorld(Point point)
        {
            double dx = (viewPort.Camera as OrthographicCamera).Width / viewPort.ActualWidth;

            LinearMath.Vector v = new LinearMath.Vector(3);
            v[0] = (point.X - viewPort.ActualWidth / 2.0) * dx + (viewPort.Camera as OrthographicCamera).Position.X;
            v[1] = (viewPort.ActualHeight / 2.0 - point.Y) * dx + (viewPort.Camera as OrthographicCamera).Position.Y;
            return(v);
        }
Пример #2
0
 private void OnMouseUp(object sender, EventArgs arg)
 {
     if (arg is MouseButtonEventArgs)
     {
         if ((arg as MouseButtonEventArgs).MiddleButton == MouseButtonState.Released)
         {
             vect = null;
         }
     }
 }
Пример #3
0
 private void OnMouseDown(object sender, EventArgs arg)
 {
     if (arg is MouseButtonEventArgs)
     {
         if ((arg as MouseButtonEventArgs).MiddleButton == MouseButtonState.Pressed)
         {
             Point p = (arg as MouseEventArgs).GetPosition(sender as Grid);
             vect = ScreenToWorld(p);
         }
     }
 }
Пример #4
0
        private void OnMouseMove(object sender, EventArgs arg)
        {
            if (arg is MouseEventArgs)
            {
                if (vect != null)
                {
                    Point             p   = (arg as MouseEventArgs).GetPosition(sender as Grid);
                    LinearMath.Vector dif = ScreenToWorld(p) - vect;

                    double X = (viewPort.Camera as OrthographicCamera).Position.X - dif[0];
                    double Y = (viewPort.Camera as OrthographicCamera).Position.Y - dif[1];
                    double Z = (viewPort.Camera as OrthographicCamera).Position.Z;

                    (viewPort.Camera as OrthographicCamera).Position = new Point3D(X, Y, Z);
                }
            }
        }