Esempio n. 1
0
 private void OnRightStateChanged(HandGestureState current, HandGestureState previous)
 {
     if (current == HandGestureState.DeselectAll)
     {
         ClearAll();
     }
 }
Esempio n. 2
0
        private void OnLeftStateChanged(HandGestureState current, HandGestureState previous)
        {
            _leftRaycastActive = (current == HandGestureState.Selection || current == HandGestureState.Deselection);

            if (current == HandGestureState.Selection)
            {
                _leftRaycastViz.material = selectionMat;
                leftSelecting            = true;
            }

            if (current == HandGestureState.Deselection)
            {
                _leftRaycastViz.material = deselectionMat;
                leftSelecting            = false;
            }

            if (_leftRaycastActive)
            {
                //_releaseListenerStartTime = Time.time;
                _isActive = true;
                if (_debuggingEnabled)
                {
                    _leftDebugCanvas.text = "Left raycast is active";
                }
            }
        }
Esempio n. 3
0
 protected virtual void OnLeftStateChanged(HandGestureState current, HandGestureState previous)
 {
     if (current == HandGestureState.DeselectAll)
     {
         _uiPrefab.SetActive(false);
     }
 }
            public HandGestureState onUpdated(Vector3 pos, float up, float foward)
            {
                obj.transform.position = pos + obj.transform.up * up + obj.transform.forward * foward;
                obj.transform.LookAt(Camera.main.transform.position);

                HandGestureState state = HandGestureState.None;

                if (dragflag)
                {
                    state = HandGestureState.Drag;
                }
                else if (pressflag)
                {
                    if (Vector3.Distance(presspos, obj.transform.position) > DragDistance)
                    {
                        state    = HandGestureState.DragStart;
                        dragflag = true;
                        if (objectcontrol != null)
                        {
                            objectcontrol.onReleased();
                        }
                    }
                    else if (Time.time - presstime > HoldTriggerTime)
                    {
                        state     = HandGestureState.Hold;
                        pressflag = false;
                        if (objectcontrol != null)
                        {
                            objectcontrol.onReleased();
                        }
                    }
                }
                return(state);
            }
Esempio n. 5
0
 private void OnLeftStateChanged(HandGestureState current, HandGestureState previous)
 {
     if (IsModeActive(Hand.Left, TransformMode.Translate))
     {
         ToggleTool(current, previous, false);
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        if (proxyManager == null)
        {
            proxyManager = FindObjectOfType <map_to_proxy>();
        }

        if (copyTo == null)
        {
            copyTo = GameObject.Find("Copy To");
        }

        activeHand = leftHand;

        // Register events for detecting active hand
        leftHand.OnGraspChanged += delegate(bool state)
        {
            if (state)
            {
                SetActiveHand(leftHand);
            }
        };

        rightHand.OnGraspChanged += delegate(bool state)
        {
            if (state)
            {
                SetActiveHand(rightHand);
            }
        };
    }
Esempio n. 7
0
        /// <summary>
        /// prevents this class from invoking a system-wide state change until
        /// the new state is confirmed to stick across a certain number of frames
        /// -- this stops single-frame hand-tracking noise (which is rampant on Quest)
        /// from causing strobe-flickering state changes
        /// </summary>
        private IEnumerator ClearFalsePositives(bool right)
        {
            int stickThreshold = 5;

            HandGestureState startingState = (right) ? currentRightHandGestureState : currentLeftHandGestureState;
            HandGestureState previousState = (right) ? previousRightState : previousLeftState;

            if (startingState == HandGestureState.DragSelection)
            {
                stickThreshold *= 2;
            }

            for (int i = 0; i < stickThreshold; i++)
            {
                yield return(new WaitForEndOfFrame());

                if (startingState != ((right) ? currentRightHandGestureState : currentLeftHandGestureState))
                {
                    yield break;
                }
            }
            if (right)
            {
                RightStateChanged?.Invoke(startingState, previousState);
            }
            else
            {
                LeftStateChanged?.Invoke(startingState, previousState);
            }
        }
Esempio n. 8
0
 private void ToggleTool(HandGestureState currentState, HandGestureState previousState, bool right)
 {
     if (currentState == HandGestureState.DragSelection)
     {
         if (right)
         {
             DragToggleHelper(true, ref rightCurrentPositionMarker, ref rightStartingPoint, _rightHandSkeleton, ref rightStickActive);
             //rightCurrentPositionMarker.position = rightStartingPoint.position = _rightHandSkeleton.Bones[(int)BoneId.Hand_ThumbTip].Transform.position;
             //rightCurrentPositionMarker.rotation = rightStartingPoint.rotation = _rightControllerMarker.transform.rotation;
             //rightStickActive = true;
             //AtomicSelection.Instance.BeginTransformation(true);
         }
         else
         {
             DragToggleHelper(true, ref leftCurrentPositionMarker, ref leftStartingPoint, _leftHandSkeleton, ref leftStickActive);
             //leftCurrentPositionMarker.position = leftStartingPoint.position = _leftHandSkeleton.Bones[(int)BoneId.Hand_ThumbTip].Transform.position;
             //leftCurrentPositionMarker.rotation = leftStartingPoint.rotation = _leftControllerMarker.transform.rotation;
             //leftStickActive = true;
             //AtomicSelection.Instance.BeginTransformation(false);
         }
         ToggleTranslateToolVisibility(true, right);
         ToggleTranslateToolColliders(true, right);
         BeginTranslationDrag?.Invoke((right) ? Hand.Right : Hand.Left);
         ADM.QLog("begin drag");
     }
     else if (previousState == HandGestureState.DragSelection && currentState != HandGestureState.DragSelection)
     {
         DisengageTranslationTool(right);
     }
 }
 private void OnLeftStateChanged(HandGestureState current, HandGestureState previous)
 {
     if (AtomicModeController.Instance.currentLeftMode == TransformMode.Rotate)
     {
         ToggleTool(current, previous, false);
     }
 }
Esempio n. 10
0
 protected override void OnLeftStateChanged(HandGestureState current, HandGestureState previous)
 {
     if (current == HandGestureState.DeselectAll)
     {
         _inputDisplay.text = _valueDisplay.text;
         _uiPrefab.SetActive(false);
     }
 }
 private void DisableHandInteraction(HandGestureState hand)
 {
     if (hand != null)
     {
         hand.hand.hoverEnabled    = false;
         hand.hand.contactEnabled  = false;
         hand.hand.graspingEnabled = false;
     }
 }
 public void SetActiveHand(HandGestureState hand)
 {
     if (curState == ProxyState.Default)
     {
         // Debug.Log("SetActiveHand: " + (hand == leftHand ? "left" : "right"));
         copyTo.GetComponent <SnapToObject>().SetRoot(hand.hand.gameObject, hand == leftHand);
         activeHand     = hand;
         activeHandGlow = hand == leftHand ? leftHandGlow : rightHandGlow;
     }
 }
Esempio n. 13
0
        private void OnLeftStateChanged(HandGestureState current, HandGestureState previous)
        {
            if (!AtomicModeController.Instance.HasFlag(AtomicModeController.Instance.currentLeftMode, TransformMode.Translate))
            {
                return;
            }

            if (current == HandGestureState.DragSelection || (current != HandGestureState.DragSelection))
            {
                ToggleTool(current, previous, false);
            }
        }
Esempio n. 14
0
 private bool ShouldToggleCreationCubeOn(bool right, HandGestureState newState, HandGestureState previous)
 {
     if (newState == HandGestureState.DragSelection && previous == HandGestureState.Neutral &&
         ((right && !AtomicModeController.Instance.rightCreationCubeInBounds) ||
          (!right && !AtomicModeController.Instance.leftCreationCubeInBounds)))
     {
         return(previous == HandGestureState.Neutral);
     }
     else
     {
         return(false);
     }
 }
        private void ToggleTool(HandGestureState currentState, HandGestureState previousState, bool right)
        {
            if (currentState == HandGestureState.DragSelection &&
                (previousState == HandGestureState.Selection || previousState == HandGestureState.Neutral))
            {
                if (right && !rightStickActive)
                {
                    rightCurrentPositionMarker.position = rightStartingPoint.position = rightStartingPoint.position = _rightHandSkeleton.Bones[(int)BoneId.Hand_ThumbTip].Transform.position;
                    rightStartingPoint.rotation         = _rightControllerMarker.transform.rotation;
                    currentRightUpAxis = rightStartingPoint.up;
                    rightCurrentPositionMarker.rotation = currentPivot.rotation;
                    rightStickActive = true;
                    AtomicSelection.Instance.BeginTransformation(true);
                    BeginRotationGearToggler(true);
                    ToggleVisibility(true, true);
                    ToggleColliders(true, true);
                    BeginRotationDrag?.Invoke(Hand.Right);
                    //ADM.QLog("begin drag");
                }
                else if (!right && !leftStickActive)
                {
                    leftCurrentPositionMarker.position = leftStartingPoint.position = _leftHandSkeleton.Bones[(int)BoneId.Hand_ThumbTip].Transform.position;
                    leftStartingPoint.rotation         = _leftControllerMarker.transform.rotation;
                    currentLeftUpAxis = leftStartingPoint.up;
                    leftCurrentPositionMarker.rotation = currentPivot.rotation;
                    leftStickActive = true;
                    AtomicSelection.Instance.BeginTransformation(false);
                    BeginRotationGearToggler(false);
                    ToggleVisibility(true, false);
                    ToggleColliders(true, false);
                    BeginRotationDrag?.Invoke(Hand.Left);
                    //ADM.QLog("begin drag");
                }
            }
            else if (currentState == HandGestureState.Stop)
            {
                if (right)
                {
                    DisengageRotationTool(true, ref rightStickActive, ref rightLineRenderer);
                }
                else
                {
                    DisengageRotationTool(false, ref leftStickActive, ref leftLineRenderer);
                }

                EndRotationDrag?.Invoke((right) ? Hand.Right : Hand.Left);
                ADM.QLog("end drag");
            }
        }
Esempio n. 16
0
 private void ToggleTool(HandGestureState currentState, HandGestureState previousState, bool right)
 {
     if (currentState == HandGestureState.DragSelection)
     {
         if (right)
         {
             rightStartingPoint.position         = _rightControllerMarker.transform.position + _hand2HUDOffset;
             rightStartingPoint.rotation         = _rightControllerMarker.transform.rotation;
             rightCurrentPositionMarker.position = _rightControllerMarker.transform.position + _hand2HUDOffset;
             rightCurrentPositionMarker.rotation = _rightControllerMarker.transform.rotation;
             rightStickActive = true;
             AtomicSelection.Instance.BeginTransformation(true);
         }
         else
         {
             leftStartingPoint.position         = _leftControllerMarker.transform.position + _hand2HUDOffset;
             leftStartingPoint.rotation         = _leftControllerMarker.transform.rotation;
             leftCurrentPositionMarker.position = _leftControllerMarker.transform.position + _hand2HUDOffset;
             leftCurrentPositionMarker.rotation = _leftControllerMarker.transform.rotation;
             leftStickActive = true;
             AtomicSelection.Instance.BeginTransformation(false);
         }
         ToggleTranslateToolVisibility(true, right);
         ToggleTranslateToolColliders(true, right);
         BeginTranslationDrag?.Invoke((right) ? Hand.Right : Hand.Left);
         Debug.Log("begin drag");
     }
     else if (previousState == HandGestureState.DragSelection && currentState != HandGestureState.DragSelection)
     {
         ToggleTranslateToolVisibility(false, right);
         ToggleTranslateToolColliders(false, right);
         if (right)
         {
             rightLineRenderer.SetPositions(new Vector3[] { Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero });
             rightStickActive = false;
             AtomicSelection.Instance.CompleteTransformation(true);
         }
         else
         {
             leftLineRenderer.SetPositions(new Vector3[] { Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero });
             leftStickActive = false;
             AtomicSelection.Instance.CompleteTransformation(false);
         }
         EndTranslationDrag?.Invoke((right) ? Hand.Right : Hand.Left);
         Debug.Log("end drag");
     }
 }
 private void OnRightControllerStateChanged(HandGestureState current, HandGestureState previous)
 {
     if (current == HandGestureState.SqueezeAll && !_rightModeMenuActive)
     {
         _rightModeMenuActive          = true;
         _potentialRightMode           = currentRightMode;
         _rightPositionMarker.position = _rightHandMarker.transform.position + _rightHand.PointerPose.forward * 0.2f;
         _rightPositionMarker.LookAt(new Vector3(rightCam.transform.position.x, _rightPositionMarker.position.y, rightCam.transform.position.z));
         ToggleVisibility(true, true);
     }
     else if (current != HandGestureState.SqueezeAll && _rightModeMenuActive)
     {
         _rightModeMenuActive = false;
         TransformMode previousMode = currentRightMode;
         currentRightMode = _potentialRightMode;
         RightModeChanged?.Invoke(currentRightMode, previousMode);
         ToggleVisibility(false, true);
     }
 }
Esempio n. 18
0
        /// <summary>
        /// Refactors duplicate code for each hand in the update loop used to check
        /// whether a state change is needed this frame
        /// </summary>
        private void CheckForUpdates(bool right, ref HandGestureState current, ref HandGestureState previous, ref OVRHand hand, ref OVRSkeleton skeleton)
        {
            string handName = (right) ? "Right" : "Left";

            previous = current;
            if (!hand.IsTracked)
            {
                UpdateHandInput(true, handName + " not found", HandGestureState.Neutral);
            }
            else if (IsFistClosedThumbOut(skeleton))
            {
                UpdateHandInput(true, handName + " fist closed thumb out", HandGestureState.Stop);
            }
            else if (IsFistClosed(skeleton))
            {
                UpdateHandInput(true, handName + " fist closed", HandGestureState.SqueezeAll);
            }
            else if (hand.GetFingerIsPinching(OVRHand.HandFinger.Index))
            {
                UpdateHandInput(true, handName + " Index Finger is pinching", HandGestureState.Insert);
            }
            else if (hand.GetFingerIsPinching(OVRHand.HandFinger.Middle))
            {
                UpdateHandInput(true, handName + " Middle Finger is pinching", HandGestureState.DragSelection);
            }
            else if (IsPointingUpward(skeleton, true))
            {
                UpdateHandInput(true, handName + " pointing upward", HandGestureState.DeselectAll);
            }
            else if (IsPointingWithPalmDown(skeleton, true))
            {
                UpdateHandInput(true, handName + " hand pointing", HandGestureState.Deselection);
            }
            else if (IsPalmFlatDownThumbOut(skeleton, true))
            {
                UpdateHandInput(true, handName + " palm is flat and thumb is out", HandGestureState.Selection);
            }
            else
            {
                UpdateHandInput(true, handName + " neutral", HandGestureState.Neutral);
            }
        }
Esempio n. 19
0
        private void OnLeftStateChanged(HandGestureState current, HandGestureState previous)
        {
            if (!(AtomicModeController.Instance.currentLeftMode == TransformMode.Scale))
            {
                return;
            }

            if (current == HandGestureState.Insert && !_isLeftScaling)
            {
                ToggleScalingState(true, false);
            }
            else if (current != HandGestureState.Insert && _isLeftScaling)
            {
                ToggleScalingState(false, false);
            }
            else
            {
                ToggleTool(current, previous, false);
            }
        }
    private void Awake()
    {
        rightHandState = new TouchStates();
        leftHandState  = new TouchStates();
        currentRightHandGestureState = HandGestureState.Neutral;
        currentLeftHandGestureState  = HandGestureState.Neutral;
        currentRightRotationState    = RotationState.lowerCase;
        currentLeftRotationState     = RotationState.lowerCase;

        // track whether a currently held finger has passed the hold action threshold
        // index values match the order of the TouchStates enum
        rightHeldLong = new bool[3] {
            false, false, false
        };
        leftHeldLong = new bool[3] {
            false, false, false
        };

        _selectionRightStartingMarker = new GameObject("RightStartMarker");
        _selectionLeftStartingMarker  = new GameObject("LeftStartMarker");
    }
            public HandGestureState onReleased()
            {
                HandGestureState state = HandGestureState.None;

                if (Time.time - presstime < PressIntervalTime)
                {
                    state = HandGestureState.Tap;
                    if (Time.time - taptime < PressIntervalTime)
                    {
                        state = HandGestureState.DoubleTap;
                    }
                }
                taptime   = Time.time;
                pressflag = false;
                dragflag  = false;
                if (objectcontrol != null)
                {
                    objectcontrol.onReleased();
                }
                return(state);
            }
Esempio n. 22
0
        private void ActivateNewState(HandGestureState newState, bool right)
        {
            if (right)
            {
                currentRightHandGestureState = newState;
                if (currentRightHandGestureState != previousRightState)
                {
                    RightStateChanged?.Invoke(currentRightHandGestureState, previousRightState);
                    Debug.Log("OculusHandInput: RightStateChange invoked - newState: " + newState);
                }

                //StartCoroutine(ClearFalsePositives(true));
            }
            else
            {
                currentLeftHandGestureState = newState;
                if (currentLeftHandGestureState != previousLeftState)
                {
                    //StartCoroutine(ClearFalsePositives(false));
                    LeftStateChanged?.Invoke(currentLeftHandGestureState, previousLeftState);
                }
            }
        }
Esempio n. 23
0
 /// <summary>
 /// Refactors code duplicated for each hand in the UpdatHandInput Method
 /// </summary>
 private void UpdateHandInputHelper(bool right, ref HandGestureState newState, ref bool dragSelectToggle, ref HandGestureState current, ref HandGestureState previous)
 {
     if (newState == HandGestureState.DragSelection &&
         (previous != HandGestureState.DragSelection && previous != HandGestureState.Stop))
     {
         if (dragSelectToggle && !CheckForTextDragLock(right))
         {
             current  = newState = HandGestureState.Stop;
             previous = HandGestureState.DragSelection;
         }
         dragSelectToggle = !dragSelectToggle;
         modeActive       = dragSelectToggle;
         ModeActiveStateChanged?.Invoke(modeActive);
         ActivateNewState(newState, right);
     }
     else if (newState == HandGestureState.Stop)
     {
         dragSelectToggle = false;
         ActivateNewState(newState, right);
     }
     else if (dragSelectToggle)
     {
         TransformMode currentMode = (right) ? AtomicModeController.Instance.currentRightMode : AtomicModeController.Instance.currentLeftMode;
         if (newState == HandGestureState.Insert || currentMode == TransformMode.Scale)
         {
             ActivateNewState(newState, right);
         }
         else
         {
             current = newState;
         }
     }
     else
     {
         ActivateNewState(newState, right);
     }
 }
Esempio n. 24
0
 private void LeftStateChangedFromHandInput(HandGestureState current, HandGestureState previous)
 {
     currentLeftHandGestureState = current;
     OnLeftStateChanged?.Invoke(current, previous);
 }
    void UpdateHandState(bool right)
    {
        //ADM.QLog("updating hand state for " + ((right) ? "right " : "left ") + "hand.");
        //ADM.QLog("Current state: " + currentRightHandGestureState +
        //       " middle " + (((rightHandState & TouchStates.middle) != 0) ? "on" : "off")
        //    + " pointer " + (((rightHandState & TouchStates.pointer) != 0) ? "on" : "off")
        //    + " thumb " + (((rightHandState & TouchStates.thumb) != 0) ? "on" : "off")
        //);
        HandGestureState previousState = (right) ? currentRightHandGestureState : currentLeftHandGestureState;

        if (right)
        {
            // Selection conditions: middle down, pointer up, thumb up
            if (currentRightHandGestureState != HandGestureState.Selection &&
                (rightHandState & TouchStates.middle) != 0 &&
                (rightHandState & TouchStates.pointer) == 0 &&
                (rightHandState & TouchStates.thumb) == 0)
            {
                currentRightHandGestureState = HandGestureState.Selection;
                _selectionRightStartingMarker.transform.position = RightMarker.Instance.transform.position;
                _selectionRightStartingMarker.transform.rotation = RightMarker.Instance.transform.rotation;
            }

            // Insertion conditions: all three down
            if (currentRightHandGestureState != HandGestureState.Neutral &&
                currentRightHandGestureState != HandGestureState.Insert &&
                (rightHandState & TouchStates.middle) != 0 &&
                (rightHandState & TouchStates.pointer) != 0 &&
                (rightHandState & TouchStates.thumb) != 0)
            {
                currentRightHandGestureState = HandGestureState.Insert;
            }

            // SqueezeAll conditions: all three down from neutral
            if (currentRightHandGestureState == HandGestureState.Neutral &&
                (rightHandState & TouchStates.middle) != 0 &&
                (rightHandState & TouchStates.pointer) != 0 &&
                (rightHandState & TouchStates.thumb) != 0)
            {
                currentRightHandGestureState = HandGestureState.SqueezeAll;
            }

            // DragSelection conditions: middle and thumb down, pointer up
            if (currentRightHandGestureState != HandGestureState.DragSelection &&
                (rightHandState & TouchStates.middle) != 0 &&
                (rightHandState & TouchStates.pointer) == 0 &&
                (rightHandState & TouchStates.thumb) != 0)
            {
                currentRightHandGestureState = HandGestureState.DragSelection;
            }

            // Neutral condtions: all up
            if (currentRightHandGestureState != HandGestureState.Neutral &&
                (rightHandState & TouchStates.middle) == 0 &&
                (rightHandState & TouchStates.pointer) == 0 &&
                (rightHandState & TouchStates.thumb) == 0)
            {
                currentRightHandGestureState = HandGestureState.Neutral;
            }

            // Click conditions:
            if (currentRightHandGestureState != HandGestureState.Click &&
                (rightHandState & TouchStates.middle) != 0 &&
                (rightHandState & TouchStates.pointer) != 0 &&
                (rightHandState & TouchStates.thumb) == 0)
            {
                currentRightHandGestureState = HandGestureState.Click;
            }

            RightStateChanged?.Invoke(currentRightHandGestureState, previousState);
        }
        else
        {
            if (currentLeftHandGestureState != HandGestureState.Selection &&
                (leftHandState & TouchStates.middle) != 0 &&
                (leftHandState & TouchStates.pointer) == 0 &&
                (leftHandState & TouchStates.thumb) == 0)
            {
                currentLeftHandGestureState = HandGestureState.Selection;
                _selectionLeftStartingMarker.transform.position = LeftMarker.Instance.transform.position;
                _selectionLeftStartingMarker.transform.rotation = LeftMarker.Instance.transform.rotation;
            }

            if (currentRightHandGestureState != HandGestureState.Neutral &&
                currentRightHandGestureState != HandGestureState.Insert &&
                (leftHandState & TouchStates.middle) != 0 &&
                (leftHandState & TouchStates.pointer) != 0 &&
                (leftHandState & TouchStates.thumb) != 0)
            {
                currentLeftHandGestureState = HandGestureState.Insert;
            }

            if (currentLeftHandGestureState == HandGestureState.Neutral &&
                (leftHandState & TouchStates.middle) != 0 &&
                (leftHandState & TouchStates.pointer) != 0 &&
                (leftHandState & TouchStates.thumb) != 0)
            {
                currentLeftHandGestureState = HandGestureState.SqueezeAll;
            }

            if (currentLeftHandGestureState != HandGestureState.DragSelection &&
                (leftHandState & TouchStates.middle) != 0 &&
                (leftHandState & TouchStates.pointer) == 0 &&
                (leftHandState & TouchStates.thumb) != 0)
            {
                currentLeftHandGestureState = HandGestureState.DragSelection;
            }

            if (currentLeftHandGestureState != HandGestureState.Neutral &&
                (leftHandState & TouchStates.middle) == 0 &&
                (leftHandState & TouchStates.pointer) == 0 &&
                (leftHandState & TouchStates.thumb) == 0)
            {
                currentLeftHandGestureState = HandGestureState.Neutral;
            }

            if (currentLeftHandGestureState != HandGestureState.Click &&
                (leftHandState & TouchStates.middle) != 0 &&
                (leftHandState & TouchStates.pointer) != 0 &&
                (leftHandState & TouchStates.thumb) == 0)
            {
                currentLeftHandGestureState = HandGestureState.Click;
            }

            LeftStateChanged?.Invoke(currentLeftHandGestureState, previousState);
        }
    }
Esempio n. 26
0
 private bool DenoisingCriteriaMet(bool right, HandGestureState newState, HandGestureState previous)
 {
     return((right && !AtomicModeController.Instance.rightCreationCubeInBounds && newState == HandGestureState.Insert) ||
            (!right && !AtomicModeController.Instance.leftCreationCubeInBounds && newState == HandGestureState.Insert));
 }
        private void onReleased(HandsInteractionManager.HandPointClass hand)
        {
            HandObjectClass obj;

            if (HandObjects.TryGetValue(hand.id, out obj))
            {
                HandGestureState state = obj.onReleased();
                if (HandObjects.Count == 1)
                {
                    if (state == HandGestureState.Tap)
                    {
                        if (HandGestureEvent != null)
                        {
                            HandGestureEvent(state);
                        }
                    }
                    else if (state == HandGestureState.DoubleTap)
                    {
                        if (HandGestureEvent != null)
                        {
                            HandGestureEvent(state);
                        }
                    }
                }
                else
                {
                    foreach (var item in HandObjects.Values)
                    {
                        if (item.GetPress())
                        {
                            return;
                        }
                    }
                    if (multipressflag)
                    {
                        if (Time.time - multipresstime < PressIntervalTime)
                        {
                            if (Time.time - multitaptime < PressIntervalTime)
                            {
                                if (HandGestureEvent != null)
                                {
                                    HandGestureEvent(HandGestureState.MultiDoubleTap);
                                }
                            }
                            else
                            {
                                if (HandGestureEvent != null)
                                {
                                    HandGestureEvent(HandGestureState.MultiTap);
                                }
                            }
                        }
                        multipressflag = false;
                        multitaptime   = Time.time;
                    }
                    else
                    {
                        if (state == HandGestureState.Tap)
                        {
                            if (HandGestureEvent != null)
                            {
                                HandGestureEvent(HandGestureState.ShiftTap);
                            }
                        }
                        else if (state == HandGestureState.DoubleTap)
                        {
                            if (HandGestureEvent != null)
                            {
                                HandGestureEvent(HandGestureState.ShiftDoubleTap);
                            }
                        }
                    }
                }
            }
            if (HandGestureEvent != null)
            {
                HandGestureEvent(HandGestureState.Release);
            }
        }
        private void onUpdated(HandsInteractionManager.HandPointClass hand)
        {
            HandObjectClass obj;

            if (HandObjects.TryGetValue(hand.id, out obj))
            {
                HandGestureState state = obj.onUpdated(hand.pos, Offset_up, Offset_foward);
                if (HandObjects.Count == 1)
                {
                    if (state == HandGestureState.Hold)
                    {
                        if (HandGestureEvent != null)
                        {
                            HandGestureEvent(state);
                        }
                    }
                    else if (state == HandGestureState.DragStart)
                    {
                        if (SingleHandGestureEvent != null)
                        {
                            SingleHandGestureEvent(state, obj.GetPosition());
                        }
                    }
                    else if (state == HandGestureState.Drag)
                    {
                        if (SingleHandGestureEvent != null)
                        {
                            SingleHandGestureEvent(state, obj.GetPosition());
                        }
                    }
                }
                else
                {
                    int       dragcount = 0;
                    Vector3[] pos       = new Vector3[2];
                    foreach (var item in HandObjects.Values)
                    {
                        if (item.GetPress())
                        {
                            pos[dragcount] = item.GetPosition();
                            dragcount++;
                        }
                    }
                    if (dragcount == 2)
                    {
                        if (Time.time - multipresstime > PressIntervalTime)
                        {
                            if (multihandflag == false)
                            {
                                if (MultiHandGestureEvent != null)
                                {
                                    MultiHandGestureEvent(HandGestureState.MultiDragStart, pos[0], pos[1]);
                                }
                                multihandflag = true;
                            }
                            else
                            {
                                if (MultiHandGestureEvent != null)
                                {
                                    MultiHandGestureEvent(HandGestureState.MultiDrag, pos[0], pos[1]);
                                }
                            }
                        }
                        obj.SetHandObjectControlRelease();
                    }
                    else
                    {
                        if (multihandflag)
                        {
                            if (dragcount == 0)
                            {
                                multihandflag = false;
                            }
                        }
                        else
                        {
                            if (state == HandGestureState.Hold)
                            {
                                if (HandGestureEvent != null)
                                {
                                    HandGestureEvent(HandGestureState.ShiftHold);
                                }
                            }
                            else if (state == HandGestureState.DragStart)
                            {
                                if (SingleHandGestureEvent != null)
                                {
                                    SingleHandGestureEvent(HandGestureState.ShiftDragStart, obj.GetPosition());
                                }
                            }
                            else if (state == HandGestureState.Drag)
                            {
                                if (SingleHandGestureEvent != null)
                                {
                                    SingleHandGestureEvent(HandGestureState.ShiftDrag, obj.GetPosition());
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 29
0
 private void RightStateChangedFromTouchInput(HandGestureState current, HandGestureState previous)
 {
     currentRightHandGestureState = current;
     OnRightStateChanged?.Invoke(current, previous);
 }
Esempio n. 30
0
 private void RightStateChangedFromHandInput(HandGestureState current, HandGestureState previous)
 {
     Debug.Log("AtomicInput RightStateChangedFromHandInput - current: " + current + " previous: " + previous);
     currentRightHandGestureState = current;
     OnRightStateChanged?.Invoke(current, previous);
 }