public Vector3D Move(Ray3D ray)
 {
     if (!isMoving) return new Vector3D();
     Vector3D t = Vector3D.CrossProduct(ray.Direction, Direction);
     Vector3D n = Vector3D.CrossProduct(Direction, t);
     var i = ray.PlaneIntersection(Origin, n);
     if (!i.HasValue)
         return new Vector3D();
     Point3D mousePoint = i.Value;
     double x = 0;
     double y = 0;
     double z = 0;
     switch (Type)
     {
         case ManipulatorType.TranslateX:
             x = mousePoint.X - _lastMousePoint.X;
             break;
         case ManipulatorType.TranslateY:
             y = mousePoint.Y - _lastMousePoint.Y;
             break;
         case ManipulatorType.TranslateZ:
             z = mousePoint.Z - _lastMousePoint.Z;
             break;
     }
     _lastMousePoint = mousePoint;
     var delta = new Vector3D(x, y, z);
     /* TranslateTransform3D transform = this.Transform as TranslateTransform3D;
     transform.OffsetX += x;
     transform.OffsetY += y;
     transform.OffsetZ += z;*/
     return delta;
 }
Esempio n. 2
0
        /// <summary>
        /// Unproject a point from the screen (2D) to a point on plane (3D)
        /// </summary>
        /// <param name="p"></param>
        /// <param name="position">plane position</param>
        /// <param name="normal">plane normal</param>
        /// <returns></returns>
        public Point3D?UnProject(Point p, Point3D position, Vector3D normal)
        {
            Ray3D ray = GetRay(p);

            if (ray == null)
            {
                return(null);
            }
            return(ray.PlaneIntersection(position, normal));
        }
 public void InitMove(Ray3D ray)
 {
     Vector3D t = Vector3D.CrossProduct(ray.Direction, Direction);
     Vector3D n = Vector3D.CrossProduct(Direction, t);
     var intersection=ray.PlaneIntersection(Origin, n);
     if (!intersection.HasValue)
         return;
     _mouseDownPoint = intersection.Value;
     _lastMousePoint = _mouseDownPoint;
     originalMaterial = Material;
     Fill = Brushes.Yellow;
     isMoving = true;
 }
Esempio n. 4
0
        public void InitMove(Ray3D ray)
        {
            Vector3D t            = Vector3D.CrossProduct(ray.Direction, Direction);
            Vector3D n            = Vector3D.CrossProduct(Direction, t);
            var      intersection = ray.PlaneIntersection(Origin, n);

            if (!intersection.HasValue)
            {
                return;
            }
            _mouseDownPoint  = intersection.Value;
            _lastMousePoint  = _mouseDownPoint;
            originalMaterial = Material;
            Fill             = Brushes.Yellow;
            isMoving         = true;
        }
Esempio n. 5
0
        public Vector3D Move(Ray3D ray)
        {
            if (!isMoving)
            {
                return(new Vector3D());
            }
            Vector3D t = Vector3D.CrossProduct(ray.Direction, Direction);
            Vector3D n = Vector3D.CrossProduct(Direction, t);
            var      i = ray.PlaneIntersection(Origin, n);

            if (!i.HasValue)
            {
                return(new Vector3D());
            }
            Point3D mousePoint = i.Value;
            double  x          = 0;
            double  y          = 0;
            double  z          = 0;

            switch (Type)
            {
            case ManipulatorType.TranslateX:
                x = mousePoint.X - _lastMousePoint.X;
                break;

            case ManipulatorType.TranslateY:
                y = mousePoint.Y - _lastMousePoint.Y;
                break;

            case ManipulatorType.TranslateZ:
                z = mousePoint.Z - _lastMousePoint.Z;
                break;
            }
            _lastMousePoint = mousePoint;
            var delta = new Vector3D(x, y, z);

            /* TranslateTransform3D transform = this.Transform as TranslateTransform3D;
             * transform.OffsetX += x;
             * transform.OffsetY += y;
             * transform.OffsetZ += z;*/
            return(delta);
        }