コード例 #1
0
        public void GrabUsingMouseRect(
            Rect screenSpaceGrabRect,
            bool allowMultigrab
            )
        {
            var selectables = GetSceneSelectables();

            if (selectables.Count == 0)
            {
                return;
            }

            foreach (var selectable in selectables)
            {
                var screenSpacePosition =
                    ActiveRenderer.GetStandardScreenSpacePosition(
                        selectable.WorldPosition
                        );
                if (!screenSpacePosition.HasValue)
                {
                    continue;
                }
                if (screenSpaceGrabRect.Contains(screenSpacePosition.Value))
                {
                    _scene.GrabObject(selectable);
                }
            }
        }
コード例 #2
0
        private void UpdateManipulatorInfo()
        {
            var cursorScreenPos   = ActiveRenderer.GetStandardScreenSpacePosition(_scene.Manipulator.Position);
            var cursorViewPosInfo = cursorScreenPos.HasValue
                ? String.Format("Cursor screen position: ({0:0.##} ; {1:0.##})", cursorScreenPos.Value.X,
                                cursorScreenPos.Value.Y)
                : "Cursor screen position: <Clipped>";

            CursorReadableInfo = String.Format("Cursor world position: ({0:0.##} ; {1:0.##} ; {2:0.##}) {3}",
                                               _scene.Manipulator.Position.X, _scene.Manipulator.Position.Y, _scene.Manipulator.Position.Z,
                                               cursorViewPosInfo);
        }
コード例 #3
0
        public void GrabUsingMouse(
            Point screenSpaceClick,
            bool allowMultigrab,
            double limit = 0.2
            )
        {
            var selectables = GetSceneSelectables();

            if (selectables.Count == 0)
            {
                return;
            }

            ISceneSelectable closestObject = null;
            var closestDistance            = double.MaxValue;

            foreach (var selectable in selectables)
            {
                var screenSpacePosition = ActiveRenderer
                                          .GetStandardScreenSpacePosition(selectable.WorldPosition);
                if (!screenSpacePosition.HasValue)
                {
                    continue;
                }
                var candidateLength =
                    (screenSpacePosition.Value - screenSpaceClick).Length;
                if (candidateLength >= closestDistance)
                {
                    continue;
                }
                closestObject   = selectable;
                closestDistance = candidateLength;
            }

            if (closestObject == null || closestDistance > limit)
            {
                return;
            }

            if (allowMultigrab)
            {
                _scene.ToggleObjectGrab(closestObject);
            }
            else
            {
                _scene.SetObjectGrab(closestObject);
            }
        }