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; }
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; }
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); }
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; }
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); }
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); }