コード例 #1
0
ファイル: Swoosher.xaml.cs プロジェクト: Shine6Z/GenXSource
        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;
            }
        }
コード例 #2
0
ファイル: Swoosher.xaml.cs プロジェクト: Shine6Z/GenXSource
 private void canvas_MouseButtonDown(object sender, MouseEventArgs e)
 {
     mouseDown      = true;
     anchorPosition = Trackball.ProjectToTrackball(Width, Height, e.GetPosition(root));
 }