示例#1
0
 public void StopDraggingModifier()
 {
     _draggingModifier = DraggingModifier.None;
 }
示例#2
0
        private static double GetRadius_Ball(Vector3D scale, DraggingModifier whichBall)
        {
            const double MINSIZE = 1.2d;

            double largestScale;
            switch (whichBall)
            {
                case DraggingModifier.BallX1:
                case DraggingModifier.BallX2:
                    //largestScale = Math.Max(scale.Y, scale.Z);
                    largestScale = scale.X;
                    break;

                case DraggingModifier.BallY1:
                case DraggingModifier.BallY2:
                    //largestScale = Math.Max(scale.X, scale.Z);
                    largestScale = scale.Y;
                    break;

                case DraggingModifier.BallZ1:
                case DraggingModifier.BallZ2:
                    //largestScale = Math.Max(scale.X, scale.Y);
                    largestScale = scale.Z;
                    break;

                default:
                    throw new ApplicationException("Unexpected DraggingModifier: " + whichBall.ToString());
            }

            double retVal = (Math.Sqrt(2d) * largestScale * .5d) + MINSIZE;
            if (retVal < MINSIZE)
            {
                retVal = MINSIZE;
            }

            return retVal;
        }
示例#3
0
        public void StartDraggingModifier(Visual3D hitVisual, Point clickPoint)
        {
            #region Arrows

            if (_arrowX1 != null && _arrowX1.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.ArrowX1;
                _arrowX1.DragAxis = GetArrowRay(_draggingModifier);
                _arrowX1.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }
            else if (_arrowX2 != null && _arrowX2.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.ArrowX2;
                _arrowX2.DragAxis = GetArrowRay(_draggingModifier);
                _arrowX2.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }
            else if (_arrowY1 != null && _arrowY1.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.ArrowY1;
                _arrowY1.DragAxis = GetArrowRay(_draggingModifier);
                _arrowY1.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }
            else if (_arrowY2 != null && _arrowY2.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.ArrowY2;
                _arrowY2.DragAxis = GetArrowRay(_draggingModifier);
                _arrowY2.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }
            else if (_arrowZ1 != null && _arrowZ1.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.ArrowZ1;
                _arrowZ1.DragAxis = GetArrowRay(_draggingModifier);
                _arrowZ1.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }
            else if (_arrowZ2 != null && _arrowZ2.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.ArrowZ2;
                _arrowZ2.DragAxis = GetArrowRay(_draggingModifier);
                _arrowZ2.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }

            #endregion
            #region Rings

            else if (_ringX != null && _ringX.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.RingX;

                Point3D circleCenter;
                Quaternion circleOrientation;
                GetRingLocation(out circleCenter, out circleOrientation);
                _ringX.CircleCenter = circleCenter;
                _ringX.CircleOrientation = circleOrientation;

                _ringX.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }
            else if (_ringY != null && _ringY.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.RingY;

                Point3D circleCenter;
                Quaternion circleOrientation;
                GetRingLocation(out circleCenter, out circleOrientation);
                _ringY.CircleCenter = circleCenter;
                _ringY.CircleOrientation = circleOrientation;

                _ringY.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }
            else if (_ringZ != null && _ringZ.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.RingZ;

                Point3D circleCenter;
                Quaternion circleOrientation;
                GetRingLocation(out circleCenter, out circleOrientation);
                _ringZ.CircleCenter = circleCenter;
                _ringZ.CircleOrientation = circleOrientation;

                _ringZ.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }

            #endregion
            #region Balls

            else if (_ballX1 != null && _ballX1.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.BallX1;

                Point3D sphereCenter;
                Quaternion sphereOrientation;
                GetRingLocation(out sphereCenter, out sphereOrientation);
                _ballX1.SphereCenter = sphereCenter;
                _ballX1.SphereOrientation = sphereOrientation;

                _ballX1.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }
            else if (_ballX2 != null && _ballX2.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.BallX2;

                Point3D sphereCenter;
                Quaternion sphereOrientation;
                GetRingLocation(out sphereCenter, out sphereOrientation);
                _ballX2.SphereCenter = sphereCenter;
                _ballX2.SphereOrientation = sphereOrientation;

                _ballX2.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }
            else if (_ballY1 != null && _ballY1.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.BallY1;

                Point3D sphereCenter;
                Quaternion sphereOrientation;
                GetRingLocation(out sphereCenter, out sphereOrientation);
                _ballY1.SphereCenter = sphereCenter;
                _ballY1.SphereOrientation = sphereOrientation;

                _ballY1.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }
            else if (_ballY2 != null && _ballY2.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.BallY2;

                Point3D sphereCenter;
                Quaternion sphereOrientation;
                GetRingLocation(out sphereCenter, out sphereOrientation);
                _ballY2.SphereCenter = sphereCenter;
                _ballY2.SphereOrientation = sphereOrientation;

                _ballY2.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }
            else if (_ballZ1 != null && _ballZ1.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.BallZ1;

                Point3D sphereCenter;
                Quaternion sphereOrientation;
                GetRingLocation(out sphereCenter, out sphereOrientation);
                _ballZ1.SphereCenter = sphereCenter;
                _ballZ1.SphereOrientation = sphereOrientation;

                _ballZ1.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }
            else if (_ballZ2 != null && _ballZ2.Model == hitVisual)
            {
                _draggingModifier = DraggingModifier.BallZ2;

                Point3D sphereCenter;
                Quaternion sphereOrientation;
                GetRingLocation(out sphereCenter, out sphereOrientation);
                _ballZ2.SphereCenter = sphereCenter;
                _ballZ2.SphereOrientation = sphereOrientation;

                _ballZ2.StartDrag(UtilityWPF.RayFromViewportPoint(_camera, _viewport, clickPoint));
            }

            #endregion
            else
            {
                throw new ArgumentException("The visual passed in is not a modifier");
            }
        }
示例#4
0
        private static double GetRadius_Ring(Vector3D scale, DraggingModifier whichRing)
        {
            const double MINSIZE = .8d;

            double largestScale;
            switch (whichRing)
            {
                case DraggingModifier.RingX:
                    largestScale = Math.Max(scale.Y, scale.Z);
                    break;

                case DraggingModifier.RingY:
                    largestScale = Math.Max(scale.X, scale.Z);
                    break;

                case DraggingModifier.RingZ:
                    largestScale = Math.Max(scale.X, scale.Y);
                    break;

                default:
                    throw new ApplicationException("Unexpected DraggingModifier: " + whichRing.ToString());
            }

            double retVal = (Math.Sqrt(2d) * largestScale * .5d) + MINSIZE;
            if (retVal < MINSIZE)
            {
                retVal = MINSIZE;
            }

            return retVal;
        }
示例#5
0
        private void GetNewBalls(out DraggableModifierSphere ball1, out DraggableModifierSphere ball2, DraggingModifier whichBall)
        {
            double radius = GetRadius_Ball(this.Scale, whichBall);

            switch (whichBall)
            {
                case DraggingModifier.BallX1:
                case DraggingModifier.BallX2:
                    ball1 = new DraggableModifierSphere(new Vector3D(radius, 0, 0), _options.EditorColors);
                    ball2 = new DraggableModifierSphere(new Vector3D(-radius, 0, 0), _options.EditorColors);
                    break;

                case DraggingModifier.BallY1:
                case DraggingModifier.BallY2:
                    ball1 = new DraggableModifierSphere(new Vector3D(0, radius, 0), _options.EditorColors);
                    ball2 = new DraggableModifierSphere(new Vector3D(0, -radius, 0), _options.EditorColors);
                    break;

                case DraggingModifier.BallZ1:
                case DraggingModifier.BallZ2:
                    ball1 = new DraggableModifierSphere(new Vector3D(0, 0, radius), _options.EditorColors);
                    ball2 = new DraggableModifierSphere(new Vector3D(0, 0, -radius), _options.EditorColors);
                    break;

                default:
                    throw new ApplicationException("Unexpected DraggingModifier: " + whichBall.ToString());
            }

            _viewport.Children.Add(ball1.Model);
            _viewport.Children.Add(ball2.Model);
        }
示例#6
0
        private DraggableModifierRing GetNewRing(DraggingModifier whichRing)
        {
            DraggableModifierRing retVal;

            double radius = GetRadius_Ring(this.Scale, whichRing);

            switch (whichRing)
            {
                case DraggingModifier.RingX:
                    retVal = new DraggableModifierRing(new Quaternion(new Vector3D(0, 1, 0), 90), radius, _options.EditorColors);
                    break;

                case DraggingModifier.RingY:
                    retVal = new DraggableModifierRing(new Quaternion(new Vector3D(1, 0, 0), 90), radius, _options.EditorColors);
                    break;

                case DraggingModifier.RingZ:
                    retVal = new DraggableModifierRing(new Quaternion(new Vector3D(0, 0, 1), 0), radius, _options.EditorColors);
                    break;

                default:
                    throw new ApplicationException("Unexpected DraggingModifier: " + whichRing.ToString());
            }

            _viewport.Children.Add(retVal.Model);

            return retVal;
        }
示例#7
0
        private void GetNewArrows(out DraggableModifierArrow arrow1, out DraggableModifierArrow arrow2, DraggingModifier whichArrow)
        {
            switch (whichArrow)
            {
                case DraggingModifier.ArrowX1:
                case DraggingModifier.ArrowX2:
                    arrow1 = new DraggableModifierArrow(new Quaternion(new Vector3D(0, 1, 0), 90), _options.EditorColors);
                    arrow2 = new DraggableModifierArrow(new Quaternion(new Vector3D(0, 1, 0), -90), _options.EditorColors);
                    break;

                case DraggingModifier.ArrowY1:
                case DraggingModifier.ArrowY2:
                    arrow1 = new DraggableModifierArrow(new Quaternion(new Vector3D(1, 0, 0), -90), _options.EditorColors);
                    arrow2 = new DraggableModifierArrow(new Quaternion(new Vector3D(1, 0, 0), 90), _options.EditorColors);
                    break;

                case DraggingModifier.ArrowZ1:
                case DraggingModifier.ArrowZ2:
                    arrow1 = new DraggableModifierArrow(new Quaternion(new Vector3D(1, 0, 0), 0), _options.EditorColors);
                    arrow2 = new DraggableModifierArrow(new Quaternion(new Vector3D(1, 0, 0), 180), _options.EditorColors);
                    break;

                default:
                    throw new ApplicationException("Unexpected DraggingModifier: " + whichArrow.ToString());
            }

            _viewport.Children.Add(arrow1.Model);
            _viewport.Children.Add(arrow2.Model);
        }
示例#8
0
        private RayHitTestParameters GetArrowRay(DraggingModifier whichArrow)
        {
            Vector3D origin = new Vector3D();
            Vector3D direction = new Vector3D();

            Vector3D position = this.Position.ToVector();
            Vector3D scale = this.Scale;
            RotateTransform3D rotateTransform = new RotateTransform3D(new QuaternionRotation3D(this.Orientation));

            switch (whichArrow)
            {
                case DraggingModifier.ArrowX1:
                    origin = position + rotateTransform.Transform(new Vector3D(GetDistance_Arrow(scale.X), 0, 0));
                    direction = rotateTransform.Transform(new Vector3D(1, 0, 0));
                    break;

                case DraggingModifier.ArrowX2:
                    origin = position - rotateTransform.Transform(new Vector3D(GetDistance_Arrow(scale.X), 0, 0));
                    direction = rotateTransform.Transform(new Vector3D(-1, 0, 0));
                    break;

                case DraggingModifier.ArrowY1:
                    origin = position + rotateTransform.Transform(new Vector3D(0, GetDistance_Arrow(scale.Y), 0));
                    direction = rotateTransform.Transform(new Vector3D(0, 1, 0));
                    break;

                case DraggingModifier.ArrowY2:
                    origin = position - rotateTransform.Transform(new Vector3D(0, GetDistance_Arrow(scale.Y), 0));
                    direction = rotateTransform.Transform(new Vector3D(0, -1, 0));
                    break;

                case DraggingModifier.ArrowZ1:
                    origin = position + rotateTransform.Transform(new Vector3D(0, 0, GetDistance_Arrow(scale.Z)));
                    direction = rotateTransform.Transform(new Vector3D(0, 0, 1));
                    break;

                case DraggingModifier.ArrowZ2:
                    origin = position - rotateTransform.Transform(new Vector3D(0, 0, GetDistance_Arrow(scale.Z)));
                    direction = rotateTransform.Transform(new Vector3D(0, 0, -1));
                    break;

                default:
                    throw new ApplicationException("Unexpected DraggingModifier: " + whichArrow.ToString());
            }

            // Exit Function
            return new RayHitTestParameters(origin.ToPoint(), direction);
        }