/// <summary>
        /// During the update event, move the current interactor (containing also the
        /// trigger for detecting nearby interactableS) to the tracked position of the grip.
        ///
        /// That is the tracked wrist plus a pregenerated position and rotation offset.
        /// </summary>
        protected override void DoEveryUpdate()
        {
            base.DoEveryUpdate();

            _gripPoint.GetWorldPose(ref _trackedGripPose);
            _gripPoint.GetOffset(ref _wristToSnapOffset);

            _trackedPinchPose = _pinchPoint.GetPose();

            if (!SnapAddress.IsNullOrInvalid(_currentSnap)
                && _currentSnap.SnappedToPinch)
            {
                if (State == InteractorState.Select)
                {
                    _wristToSnapOffset.Premultiply(_snapOffset);
                }
                else
                {
                    Pose gripToPinchOffset = PoseUtils.RelativeOffset(_trackedPinchPose, _trackedGripPose);
                    _wristToSnapOffset.Premultiply(gripToPinchOffset);
                }
            }

            this.transform.SetPose(_trackedGripPose);
        }
Beispiel #2
0
        protected override void Apply(HandDataAsset data)
        {
            Pose rootToPointer = PoseUtils.RelativeOffset(data.PointerPose, data.Root);

            rootToPointer.position = (rootToPointer.position / data.HandScale) * _scale;
            PoseUtils.Multiply(data.Root, rootToPointer, ref data.PointerPose);

            data.HandScale = _scale;
        }
        /// <summary>
        /// When a new interactable is selected, start the grab at the ideal point. When snapping is
        /// involved that can be a point in the interactable offset from the hand
        /// which will be stored to progressively reduced it in the next updates,
        /// effectively attracting the object towards the hand.
        /// When no snapping is involved the point will be the grip point of the hand directly.
        /// Note: ideally this code would be in InteractableSelected but it needs
        /// to be called before the object is marked as active.
        /// </summary>
        /// <param name="snap">The selected Snap Data </param>
        protected override void InteractableSelected(HandGrabInteractable interactable)
        {
            if (SnapAddress.IsNullOrInvalid(_currentSnap))
            {
                base.InteractableSelected(interactable);
                return;
            }

            if (_currentSnap.SnappedToPinch)
            {
                _snapOffset = PoseUtils.RelativeOffset(_trackedPinchPose, _trackedGripPose);
            }
            else
            {
                _snapOffset = Pose.identity;
            }

            Pose handGrabStartPose = PoseUtils.Multiply(_trackedGripPose, _snapOffset);
            Pose interactableGrabStartPose = _currentSnap.WorldSnapPose;
            _movement = interactable.GenerateMovement(interactableGrabStartPose, handGrabStartPose);
            base.InteractableSelected(interactable);
        }
Beispiel #4
0
        public void UpdateTarget(Pose target)
        {
            Pose grabberDelta = PoseUtils.RelativeOffset(target, _originalTarget);

            PoseUtils.Multiply(_originalSource, grabberDelta, ref _current);
        }