Example #1
0
        void Start()
        {
            handL = new HandGestureInfo();
            handR = new HandGestureInfo();

            countdown = GetComponent <Countdown>();
        }
Example #2
0
        void FixedUpdate()
        {
            handL.hand = _leftHand.GetLeapHand();
            handR.hand = _rightHand.GetLeapHand();

            if (handL.hand != null)
            {
                handL = setHand(handL);
                GestureDelegation(handL);
            }
            else
            {
                handL = resetHand(handL);
            }

            if (handR.hand != null)
            {
                handR = setHand(handR);
                GestureDelegation(handR);
            }
            else
            {
                handR = resetHand(handR);
            }
        }
Example #3
0
        //Flying phase
        private Vector3 getDirection(HandGestureInfo hand)
        {
            Vector3 dir = hand.hand.PalmNormal.ToVector3();

            dir = dir.normalized;
            return(new Vector3(dir.x, dir.y, dir.z));
        }
Example #4
0
        //---------------------------------------------------------------------------------
        //---------------------Application Specific Methods--------------------------------
        //---------------------------------------------------------------------------------
        //Track selection phase
        private bool trackSelectionPhase(HandGestureInfo hand)
        {
            HandRaycaster hr;

            if (hand.hand.IsLeft)
            {
                hr = _leftHand.GetComponent <HandRaycaster>();
            }
            else
            {
                hr = _rightHand.GetComponent <HandRaycaster>();
            }

            Vector3 palmPos = hand.hand.PalmPosition.ToVector3();
            Vector3 dir     = hand.hand.PalmNormal.ToVector3();

            Color sphereColor = Color.blue;

            if (hand.hand.IsLeft)
            {
                dir = _leftHand.transform.GetChild((int)HandJointObj.PALM).transform.GetChild(0).position;
                if (_leftCHand.getSphereMat() == null)
                {
                    return(true);
                }

                sphereColor = _leftCHand.getSphereMat().color;
            }
            else
            {
                dir = _rightHand.transform.GetChild((int)HandJointObj.PALM).transform.GetChild(0).position;
                if (_rightCHand.getSphereMat() == null)
                {
                    return(true);
                }

                sphereColor = _rightCHand.getSphereMat().color;
            }

            dir = dir - palmPos;
            dir = dir.normalized;

            //returns true if selection is complete (reversed here)
            bool enableRaycaster = hr.shootRaycast(palmPos, dir, hand.isPalmOpen, sphereColor);

            //Diabled the raycaster if the selection is complete
            if (enableRaycaster)
            {
                hr         = _leftHand.GetComponent <HandRaycaster>();
                hr.enabled = false;
                hr         = _leftHand.GetComponent <HandRaycaster>();
                hr.enabled = false;
            }

            return(!enableRaycaster);
        }
Example #5
0
        private HandGestureInfo resetHand(HandGestureInfo h)
        {
            h.isFist     = false;
            h.isPalmOpen = false;
            h.isThumbsUp = false;
            h.hand       = null;

            resetComponents();

            return(h);
        }
Example #6
0
        private void GestureDelegation(HandGestureInfo hand)
        {
            //If current phase is track selection
            if (isSelectingTrack)
            {
                isSelectingTrack = trackSelectionPhase(hand);
                isCountdown      = !isSelectingTrack;
                if (isCountdown)
                {
                    GetComponent <AudioController>().playTrackSelected();
                }
            }
            //Countdown phase
            else if (isCountdown)
            {
                if (hand.hand.IsLeft)
                {
                    countdown.setLeftThumbsUp(hand.isThumbsUp);
                }
                else
                {
                    countdown.setRightThumbsUp(hand.isThumbsUp);
                }

                if (countdown.getIsReady())
                {
                    isFlying    = true;
                    isCountdown = false;
                    countdown.startCountdown();
                }
                else
                {
                    if (hand.isThumbsDown)
                    {
                        GetComponent <PlayerPositionSwitcher>().switchPosition();
                    }
                }
            }
            //AirRace phase
            else if (isFlying)
            {
                if (hand.hand.IsLeft && GetComponent <PlayerMovement>().enabled)
                {
                    GetComponent <PlayerMovement>().setIsFlying(hand.isFist);
                }
                else
                {
                    GetComponent <PlayerMovement>().fly(getDirection(hand));
                }
            }
        }
Example #7
0
        private HandGestureInfo setHand(HandGestureInfo hand)
        {
            //Check Fist
            hand.setIsFist(hand.hand.GetFistStrength() > 0.7f);
            //Check Palm
            hand.isPalmOpen = hand.hand.GetFistStrength() < 0.13f;
            //check ThumbsUp
            float thumbPinkyDistance = hand.hand.GetThumb().TipPosition.y - hand.hand.GetPinky().TipPosition.y;
            bool  extended           = hand.hand.GetThumb().IsExtended;
            bool  closedFist         = hand.hand.GetFistStrength() > 0.78f;
            bool  isUpwards          = thumbPinkyDistance > 0.09f;
            bool  isDownwards        = thumbPinkyDistance < 0.078f;

            hand.isThumbsUp   = extended && closedFist && isUpwards;
            hand.isThumbsDown = extended && closedFist && isDownwards;

            return(hand);
        }