示例#1
0
        void HandleBeginDrag(VrEventArgs args)
        {
            _frameGfx.Visible = false;

            var hitInstruction = args.HitResult as HitResult <RsMoveInstruction>;
            var hitSegment     = args.HitResult as HitResult <PathSegment>;

            if (hitInstruction != null)
            {
                _dragOffset = args.Frame.InverseRigid() * hitInstruction.HitObject.GetToTarget().Transform.GlobalMatrix;
                WithUndo("VR Drag", () => PathEditingHelper.MoveInstructionToFrame(hitInstruction.HitObject, args.Frame * _dragOffset));
                _newHighlightTarget = hitInstruction?.HitObject?.GetToTarget();
            }
            else if (hitSegment != null)
            {
                WithUndo("VR Drag", () => _newInstruction = PathEditingHelper.InsertMoveInstruction(hitSegment.HitObject, args.Frame));
            }
            else if (args.HitResult != null)
            {
                throw new InvalidOperationException("unrecognized HitResult");
            }
            else
            {
                WithUndo("VR Create Instruction", () => _newInstruction = PathEditingHelper.CreateNewInstructionInActivePath(args.Frame));
                _dragOffset        = Matrix4.Identity;
                args.CreatedObject = () => new HitResult <RsMoveInstruction>(_newInstruction, 0, args.Frame.Translation);
            }
        }
示例#2
0
        void HandleAlternateClick(VrEventArgs args)
        {
            var hitInstruction = args.HitResult as HitResult <RsMoveInstruction>;

            if (hitInstruction != null)
            {
                WithUndo("VR Delete", () => PathEditingHelper.DeleteInstruction(hitInstruction.HitObject));
            }
        }
示例#3
0
        public override void Update(VrUpdateArgs args)
        {
            var session = args.Session;
            var input   = session.SemanticInput();

            Matrix4 pointer   = PointerFilter(session.RightController.PointerTransform);
            var     hitResult = GetClosestHit(pointer.Translation);

            //KNARK: Review Deletebutton usage (used to capture on down, execute on up)

            /*if(input.SelectClick || input.DeleteClick)
             * {
             *  _pressedAt = pointer;
             * }
             * else */if (input.IsSelectPressed && !_dragging)
            {
                _dragging  = true;
                _hitResult = hitResult;

                var eventArgs = new VrEventArgs(pointer, _hitResult);
                BeginDrag?.Invoke(eventArgs);
                if (eventArgs.CreatedObject != null)
                {
                    _hitResult = eventArgs.CreatedObject();
                }
            }
            else if (_dragging && input.IsSelectPressed)
            {
                DeltaDrag?.Invoke(new VrEventArgs(pointer, _hitResult));
            }
            else if (!input.IsSelectPressed && _dragging)
            {
                _dragging = false;
                EndDrag?.Invoke(new VrEventArgs(pointer, _hitResult));
            }
            //else if (_gripPressed && !session.RightController.InputState.GripPressed
            //    && CloseEnough(_pressedAt, pointer))
            else if (input.DeleteClick)
            {
                AlternateClick?.Invoke(new VrEventArgs(pointer, hitResult));
            }
            else if (hitResult != null)
            {
                HoverObject?.Invoke(new VrEventArgs(pointer, hitResult));
            }
        }
示例#4
0
        void HandleDeltaDrag(VrEventArgs args)
        {
            //_frameGfx.Visible = false;

            var hitInstruction = args.HitResult as HitResult <RsMoveInstruction>;
            var hitSegment     = args.HitResult as HitResult <PathSegment>;

            if (hitInstruction != null)
            {
                WithUndoAppend("VR Drag", () => PathEditingHelper.MoveInstructionToFrame(hitInstruction.HitObject, args.Frame * _dragOffset));
                _newHighlightTarget = hitInstruction?.HitObject?.GetToTarget();
                _forceUpdateLine    = true;
            }
            else if (hitSegment != null)
            {
                WithUndoAppend("VR Drag", () => PathEditingHelper.MoveInstructionToFrame(_newInstruction, args.Frame));
            }
            else if (args.HitResult != null)
            {
                throw new InvalidOperationException("unrecognized HitResult");
            }
        }
示例#5
0
        void HandleHover(VrEventArgs args)
        {
            var hitInstruction = args.HitResult as HitResult <RsMoveInstruction>;

            _newHighlightTarget = hitInstruction?.HitObject?.GetToTarget();
        }
示例#6
0
 void HandleEndDrag(VrEventArgs args)
 {
     HandleDeltaDrag(args);
     _frameGfx.Visible = true;
 }