示例#1
0
        /// <summary>
        /// Sets mouse down point.
        /// </summary>
        /// <param name="position">
        /// The position.
        /// </param>
        private void SetMouseDownPoint(Point position)
        {
            this.MouseDownPoint = position.ToVector2();
            if (!this.Controller.Viewport.FixedRotationPointEnabled && this.Controller.Viewport.FindHitsInFrustum(this.MouseDownPoint, ref hits))
            {
                if (hits.Count > 0)
                {
                    MouseDownNearestPoint3D = hits[0].PointHit;
                    if (hits[0].ModelHit is Element3D ele)
                    {
                        MouseDownNearestModelBoundCenter = ele.BoundsWithTransform.Center;
                    }
                    else if (hits[0].ModelHit is Model.Scene.SceneNode node)
                    {
                        MouseDownNearestModelBoundCenter = node.BoundsWithTransform.Center;
                    }
                }
            }
            else
            {
                MouseDownNearestModelBoundCenter = null;
                MouseDownNearestPoint3D          = null;
            }

            this.MouseDownPoint3D = this.UnProject(position);
        }
示例#2
0
        /// <summary>
        /// Occurs when the position is changed during a manipulation.
        /// </summary>
        /// <param name="e">The <see cref="Point"/> instance containing the event data.</param>
        public override void Delta(Point e)
        {
            var delta = e.ToVector2() - this.LastPoint.ToVector2();

            this.LastPoint = e;
            this.Zoom(delta.Y * 0.01, this.zoomPoint3D);
        }
        /// <summary>
        /// Sets mouse down point.
        /// </summary>
        /// <param name="position">
        /// The position.
        /// </param>
        private void SetMouseDownPoint(Point position)
        {
            this.MouseDownPoint = position.ToVector2();

            if (!this.Controller.Viewport.FixedRotationPointEnabled &&
                this.Controller.Viewport.FindNearest(position, out var nearestPoint, out var normal, out var visual))
            {
                this.MouseDownNearestPoint3D = nearestPoint;
            }
        /// <summary>
        /// Occurs when the position is changed during a manipulation.
        /// </summary>
        /// <param name="e">The <see cref="Point"/> instance containing the event data.</param>
        public override void Delta(Point e)
        {
            base.Delta(e);

            double ar    = this.Controller.Viewport.ActualHeight / this.Controller.Viewport.ActualWidth;
            var    delta = this.MouseDownPoint.ToVector2() - e.ToVector2();

            if (Math.Abs(delta.Y / delta.X) < ar)
            {
                delta.Y = (float)(Math.Sign(delta.Y) * Math.Abs(delta.X * ar));
            }
            else
            {
                delta.X = (float)(Math.Sign(delta.X) * Math.Abs(delta.Y / ar));
            }

            this.zoomRectangle = new Rect(this.MouseDownPoint, (this.MouseDownPoint.ToVector2() - delta).ToPoint());

            //this.Viewport.ShowZoomRectangle(this.zoomRectangle);
        }
示例#5
0
 /// <summary>
 /// Un-projects a point from the screen (2D) to a point on plane (3D)
 /// </summary>
 /// <param name="p">
 /// The 2D point.
 /// </param>
 /// <param name="position">
 /// plane position
 /// </param>
 /// <param name="normal">
 /// plane normal
 /// </param>
 /// <returns>
 /// A 3D point.
 /// </returns>
 public Point3D?UnProject(Point p, Point3D position, Vector3D normal)
 {
     return(UnProject(p.ToVector2(), position, normal));
 }
示例#6
0
 public static Ray UnProject(this Viewport3DX viewport, Point point2d)
 {
     return(UnProject(viewport, point2d.ToVector2()));
 }