Exemplo n.º 1
0
        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // Get the mouse in screen space.
            Point pt = e.GetPosition(Renderer.Viewport3D);

            // Obtain the Visual3D objects under the mouse pointer.
            var result     = VisualTreeHelper.HitTest(Renderer.Viewport3D, pt);
            var resultMesh = result as RayMeshGeometry3DHitTestResult;

            if (resultMesh == null)
            {
                return;
            }

            // Look up the display from all those rendered.
            dDragging     = Renderer.GetDisplay(resultMesh.VisualHit as ModelVisual3D);
            indexDragging = -1;

            // Find the index of the closest corner in that display.
            if (dDragging != null)
            {
                indexDragging = dDragging.FindClosestCornerIndex(Renderer.TransformToViewport(pt), 0.3);
            }

            // If we have a corner, update the homography.
            if (indexDragging != -1)
            {
                dDragging[indexDragging] = Renderer.TransformToViewport(pt);
            }

            // Capture the mouse.
            CaptureMouse();
        }
Exemplo n.º 2
0
 private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     // If the mouse is captured, release the capture and update the settings.
     if (IsMouseCaptured && (dDragging != null && indexDragging != -1))
     {
         dDragging     = null;
         indexDragging = -1;
         ReleaseMouseCapture();
     }
 }
Exemplo n.º 3
0
 private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     // If the mouse is captured, release the capture and update the settings.
     if (IsMouseCaptured && (dDragging != null && indexDragging != -1))
     {
         dDragging = null;
         indexDragging = -1;
         ReleaseMouseCapture();
     }
 }
Exemplo n.º 4
0
        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // Get the mouse in screen space.
            Point pt = e.GetPosition(Renderer.Viewport3D);

            // Obtain the Visual3D objects under the mouse pointer.
            var result = VisualTreeHelper.HitTest(Renderer.Viewport3D, pt);
            var resultMesh = result as RayMeshGeometry3DHitTestResult;
            if (resultMesh == null)
                return;

            // Look up the display from all those rendered.
            dDragging = Renderer.GetDisplay(resultMesh.VisualHit as ModelVisual3D);
            indexDragging = -1;

            // Find the index of the closest corner in that display.
            if (dDragging != null)
                indexDragging = dDragging.FindClosestCornerIndex(Renderer.TransformToViewport(pt), 0.3);

            // If we have a corner, update the homography.
            if (indexDragging != -1)
                dDragging[indexDragging] = Renderer.TransformToViewport(pt);

            // Capture the mouse.
            CaptureMouse();
        }