Beispiel #1
0
        private void canvas_MouseMove(object sender, MouseEventArgs e)
        {
            if (mouseDown /*&& physics == null*/)
            {
                if (!mouseCaptured)
                {
                    root.CaptureMouse();
                    mouseCaptured = true;
                }

                Vector3D position = Trackball.ProjectToTrackball(Width, Height, e.GetPosition(root));

                Vector3D axis  = Vector3D.CrossProduct(anchorPosition, position);
                double   angle = Vector3D.AngleBetween(anchorPosition, position);

                if (axis != new Vector3D())
                {
                    axis.Y *= -1;
                    Quaternion delta = new Quaternion(axis, angle);

                    camera.Rotation   *= delta;
                    camera.UpDirection = camera.GetRotationMatrix().Transform(new Vector3D(0, 1, 0));
                }

                anchorPosition = position;
                needsRefresh   = true;
            }
        }
Beispiel #2
0
 private void canvas_MouseButtonDown(object sender, MouseEventArgs e)
 {
     mouseDown      = true;
     anchorPosition = Trackball.ProjectToTrackball(Width, Height, e.GetPosition(root));
 }