/***************************************************** * IS GESTURE DETECTION * * INFO: Permet de valider la détection d'un nouveau * geste et de retourner la réponse. Permet * aussi de recuperer le type de geste en cours. * *****************************************************/ public bool IsGestureDetected() { bool isDetected = IsDetectedGesture(); if (isGestureDetected != isDetected) { isGestureDetected = isDetected; gestureDetectedType = isDetected ? DetectedGestureName() : ""; handDetected = isDetected ? DetectedHand() : HandsE.inconnu; //PlaySoundOnGesture(); } return(isDetected); }
/***************************************************** * UPDATE SWIPE SLIDERS * * INFO: Permet de demarrer le Timer du slider pour * le type de geste swipe détecté. * * *** TO OPTIMIZE *** * *****************************************************/ private void UpdateSwipeSliders() { //Recupere le type de geste détecté string gesture = GestureMediator.GetGestureType(); HandsE hand = GestureMediator.GetDetectedHand(); // Glissements de la main gauche if (hand == HandsE.gauche && gesture.Contains("Swipe")) { if (gesture == "Swipe gauche") { StartCoroutine(SwipeSliderTimer(leftHandSwipeSliders[0])); } if (gesture == "Swipe droite") { StartCoroutine(SwipeSliderTimer(leftHandSwipeSliders[1])); } if (gesture == "Swipe haut") { StartCoroutine(SwipeSliderTimer(leftHandSwipeSliders[2])); } if (gesture == "Swipe bas") { StartCoroutine(SwipeSliderTimer(leftHandSwipeSliders[3])); } } // Glissements de la main droite if (hand == HandsE.droite && gesture.Contains("Swipe")) { if (gesture == "Swipe gauche") { StartCoroutine(SwipeSliderTimer(rightHandSwipeSliders[0])); } if (gesture == "Swipe droite") { StartCoroutine(SwipeSliderTimer(rightHandSwipeSliders[1])); } if (gesture == "Swipe haut") { StartCoroutine(SwipeSliderTimer(rightHandSwipeSliders[2])); } if (gesture == "Swipe bas") { StartCoroutine(SwipeSliderTimer(rightHandSwipeSliders[3])); } } }
/***************************************************** * GET FINGER POSITION * * INFO: Supporte la rotation effectuée avec l'index * et/ou le pouce. * * Retourne la position du bout du doigt. On * met la priorité sur l'index. Sinon ce sera * avec la position du bout du pouce pour indiquer * quel sens la rotation doit prendre. * *****************************************************/ private Vector3 GetFingerPosition() { //La main utilisée pour effectuer le geste Pouce ou Index. HandsE hand = ThumbOrIndexGesture.GetInstance().GetHand(); //Si la main initialisée pour effecuer la rotation est détectée if (DetectionController.GetInstance().IsHandDetected(hand)) { Vector3 fingertip = Vector3.zero; detectedHand = DetectionController.GetInstance().GetHand(hand); if (isIndexOpen) { fingertip += detectedHand.GetFinger(FingersE.index).GetFingertipPosition(); } else if (isThumbOpen) { fingertip += detectedHand.GetFinger(FingersE.pouce).GetFingertipPosition(); } return(fingertip); } return(Vector3.zero); }
/***************************************************** * GET HAND * * INFO: Valide et retourne la bonne main (gauche ou droite). * *****************************************************/ public HandController GetHand(HandsE _hand) { return(_hand == HandsE.gauche ? leftHandController : rightHandController); }
/***************************************************** * IS HAND DETECTED * * INFO: Valide l'utilisation et la visibilité d'une * main en particulier. * *****************************************************/ public bool IsHandDetected(HandsE _hand) { bool isVisible = _hand == HandsE.gauche ? isLeftHandVisible : isRightHandVisible; return(GetHand(_hand).IsHandSet() && isVisible); }