Ejemplo n.º 1
0
        protected override void ButtonDownAction()
        {
            Vector3D vector = new Vector3D();

            switch (this.ActiveAdorner.Axis)
            {
            case Adorner3D.TransformVia.XAxis:
                vector = new Vector3D(0.0, -AdornedToolBehavior3D.sqrt2div2, AdornedToolBehavior3D.sqrt2div2);
                break;

            case Adorner3D.TransformVia.YAxis:
                vector = new Vector3D(AdornedToolBehavior3D.sqrt2div2, 0.0, -AdornedToolBehavior3D.sqrt2div2);
                break;

            case Adorner3D.TransformVia.ZAxis:
                vector = new Vector3D(-AdornedToolBehavior3D.sqrt2div2, AdornedToolBehavior3D.sqrt2div2, 0.0);
                break;

            default:
                vector = new Vector3D(0.0, AdornedToolBehavior3D.sqrt2div2, -AdornedToolBehavior3D.sqrt2div2);
                break;
            }
            this.mouseMovementAxis = AdornedToolBehavior3D.Vector3DInViewport3D(this.Selected3DElement, vector);
            this.mouseMovementAxis.Normalize();
            this.rotationAxis       = this.ActiveAdorner.RotationAxis;
            this.initialQuaternion  = Helper3D.QuaternionFromEulerAngles(this.Selected3DElement.CanonicalRotationAngles);
            this.previousQuaternion = this.initialQuaternion;
            this.previousAngle      = new double?();
            this.lastUnsnappedAngle = 0.0;
        }
Ejemplo n.º 2
0
 protected override void ButtonDownAction()
 {
     this.scaleAxis         = this.ActiveAdorner.ScaleAxis;
     this.mouseMovementAxis = AdornedToolBehavior3D.Vector3DInViewport3D(this.Selected3DElement, this.scaleAxis);
     if (Math.Abs(this.mouseMovementAxis.X) <= AdornedToolBehavior3D.tolerance && Math.Abs(this.mouseMovementAxis.Y) <= AdornedToolBehavior3D.tolerance)
     {
         this.mouseMovementAxis = new Vector(AdornedToolBehavior3D.sqrt2div2, AdornedToolBehavior3D.sqrt2div2);
     }
     this.mouseMovementAxis.Normalize();
 }
Ejemplo n.º 3
0
 protected static Vector Vector3DInViewport3D(Base3DElement target, Vector3D vector)
 {
   Viewport3D viewport = (Viewport3D) target.Viewport.ViewObject.PlatformSpecificObject;
   Matrix3D viewport3DtoElement = target.GetComputedTransformFromViewport3DToElement();
   Point point = AdornedToolBehavior3D.Point3DInViewport3D(viewport, viewport3DtoElement, new Point3D(0.0, 0.0, 0.0));
   Vector vector1 = AdornedToolBehavior3D.Point3DInViewport3D(viewport, viewport3DtoElement, (Point3D) vector) - point;
   if (vector1.Length < 0.0 / 1.0)
     return new Vector(0.0, 1.0);
   return vector1;
 }
Ejemplo n.º 4
0
 internal static Point Point3DInViewport3D(Viewport3D viewport, Matrix3D viewportToWorld, Point3D point)
 {
   Camera camera = viewport.Camera;
   Point3D point1 = viewportToWorld.Transform(point);
   Point3D point3D = Helper3D.CameraRotationTranslationMatrix(camera).Transform(point1);
   Point4D point2 = new Point4D(point3D.X, point3D.Y, point3D.Z, 1.0);
   Point4D point4D = AdornedToolBehavior3D.ProjectionMatrix(viewport.ActualWidth, viewport.ActualHeight, camera).Transform(point2);
   Point point3 = Math.Abs(point4D.W) >= 0.0 / 1.0 ? new Point(point4D.X / point4D.W, point4D.Y / point4D.W) : new Point(0.0, 0.0);
   return new Point((point3.X + 1.0) * viewport.ActualWidth / 2.0, viewport.ActualHeight * ((1.0 - point3.Y) / 2.0));
 }
Ejemplo n.º 5
0
        protected override void ButtonDownAction()
        {
            Vector3D translationAxis = this.ActiveAdorner.TranslationAxis;
            Vector3D vector3D        = this.Selected3DElement.CanonicalRotateTransform3D.Value.Transform(translationAxis);

            this.mouseMovementAxis = AdornedToolBehavior3D.Vector3DInViewport3D(this.Selected3DElement, translationAxis);
            if (Math.Abs(this.mouseMovementAxis.X) <= AdornedToolBehavior3D.tolerance && Math.Abs(this.mouseMovementAxis.Y) <= AdornedToolBehavior3D.tolerance)
            {
                this.mouseMovementAxis = new Vector(AdornedToolBehavior3D.sqrt2div2, AdornedToolBehavior3D.sqrt2div2);
            }
            this.mouseMovementAxis.Normalize();
            this.translationAxis = vector3D;
        }
Ejemplo n.º 6
0
 internal static Point3D ProjectionPoint3DTranslatedToMatchingOrthographicPosition(Viewport3D viewport, Matrix3D pointToWorldTransform, OrthographicCamera ortho, Point3D point)
 {
   Camera camera = viewport.Camera;
   Point3D point1 = pointToWorldTransform.Transform(point);
   Point3D point3D = Helper3D.CameraRotationTranslationMatrix(camera).Transform(point1);
   Point4D point2 = new Point4D(point3D.X, point3D.Y, point3D.Z, 1.0);
   Point4D point4D1 = AdornedToolBehavior3D.ProjectionMatrix(viewport.ActualWidth, viewport.ActualHeight, camera).Transform(point2);
   Point4D point3 = new Point4D(point4D1.X / point4D1.W, point4D1.Y / point4D1.W, 0.0, 1.0);
   Matrix3D matrix3D1 = AdornedToolBehavior3D.ProjectionMatrix(viewport.ActualWidth, viewport.ActualHeight, (Camera) ortho);
   if (Math.Abs(matrix3D1.Determinant) > 1E-16)
     matrix3D1.Invert();
   Point4D point4D2 = matrix3D1.Transform(point3);
   Point3D point4 = new Point3D(point4D2.X / point4D2.W, point4D2.Y / point4D2.W, point3D.Z);
   Matrix3D matrix3D2 = Helper3D.CameraRotationTranslationMatrix((Camera) ortho);
   matrix3D2.Invert();
   return matrix3D2.Transform(point4);
 }