Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     UpdateThreshold();
     new_state = hand_states.HANDS_NEUTRAL;
     if (kmc.isTracked)
     {
         right_hand_position     = kmc.Hand_Right.transform.position;
         left_hand_position      = kmc.Hand_Left.transform.position;
         right_shoulder_position = kmc.Shoulder_Right.transform.position;
         left_shoulder_position  = kmc.Shoulder_Left.transform.position;
         right_elbow_position    = kmc.Elbow_Right.transform.position;
         left_elbow_position     = kmc.Elbow_Left.transform.position;
         distanceToBodyRightY    = right_hand_position.y - right_shoulder_position.y;
         distanceToBodyLeftY     = left_hand_position.y - left_shoulder_position.y;
         distanceHandElbowLeft   = left_hand_position.y - left_elbow_position.y;
         distanceHandElbowRight  = right_hand_position.y - right_elbow_position.y;
         //on pourrait ajouter des conditions sur le x aussi
         //à affiner selon le transform que l'on mettra
         //right_hand_position = kmc.transform.position;
         NewStateUpdate();
         StateTransition();
     }
     else
     {
         b1 = false;
     }
 }
Ejemplo n.º 2
0
    override protected void NewStateUpdate()
    {
        //état initial
        //premier état distanceGauche>thresholdup et absdistanceDroite<thresholdown
        //deuxième état, mains même y ou bien dans la même tranche de y
        //3ème état, absdistanceGauche<thresholddown et absdistanceDroite>threhsoldup
        //4ème état, mains même y ou bien dans la même tranche de y
        //
        //if (Mathf.Abs(distanceToBodyRightY) < distance_threshold_down && Mathf.Abs(distanceToBodyLeftY) > distance_threshold_up)
        //    new_state = hand_states.RIGHT_UP_LEFT_DOWN;
        //else if (Mathf.Abs(distanceToBodyLeftY) < distance_threshold_down && Mathf.Abs(distanceToBodyRightY) > distance_threshold_up)
        //    new_state = hand_states.LEFT_UP_RIGHT_DOWN;
        //else if (Mathf.Abs(distanceToBodyRightY) < distance_threshold_up && Mathf.Abs(distanceToBodyRightY) > distance_threshold_down && Mathf.Abs(distanceToBodyLeftY) < distance_threshold_up && Mathf.Abs(distanceToBodyLeftY) > distance_threshold_down)
        //    new_state = hand_states.HANDS_EQUAL;
        //else { }

        if (distanceHandElbowLeft < 0 && distanceHandElbowRight > 0)
        {
            new_state = hand_states.RIGHT_UP_LEFT_DOWN;
        }
        else if (distanceHandElbowLeft > 0 && distanceHandElbowRight < 0)
        {
            new_state = hand_states.LEFT_UP_RIGHT_DOWN;
        }
        else if (Mathf.Abs(distanceHandElbowRight) < marge && Mathf.Abs(distanceHandElbowLeft) < marge)
        {
            new_state = hand_states.HANDS_EQUAL;
        }
        //if (distanceHandElbowRight > 0 && Mathf.Abs(distanceHandElbowRight) > distance_threshold_down * 0.6 && distanceHandElbowLeft < 0 && Mathf.Abs(distanceHandElbowLeft) > distance_threshold_down * 0.6)
        //{
        //    new_state = hand_states.RIGHT_UP_LEFT_DOWN;
        //}
        //else if (distanceHandElbowRight < 0 && Mathf.Abs(distanceHandElbowRight) > distance_threshold_down * 0.6 && distanceHandElbowLeft > 0 && Mathf.Abs(distanceHandElbowLeft) > distance_threshold_down * 0.6)
        //{
        //    new_state = hand_states.LEFT_UP_RIGHT_DOWN;
        //}
        //else if (Mathf.Abs(distanceHandElbowRight) < distance_threshold_down && Mathf.Abs(distanceHandElbowLeft) < distance_threshold_down)
        //{
        //    new_state = hand_states.HANDS_EQUAL;
        //}
        else
        {
        }

        b1 = false;
    }
    override protected void NewStateUpdate()
    {
        if (distanceToBodyRight > distance_threshold_up * 0.6 && distanceToBodyLeft > distance_threshold_up * 0.6)
        {
            new_state = hand_states.HANDS_HIGH;
        }
        else if (distanceToBodyRight < distance_threshold_down * 0.6 && distanceToBodyLeft < distance_threshold_down * 0.6)
        {
            new_state = hand_states.HANDS_LOW;
        }
        else if (distanceToBodyRight < distance_threshold_up * 0.6 && distanceToBodyRight > distance_threshold_down * 0.6 && distanceToBodyLeft < distance_threshold_up * 0.6 && distanceToBodyLeft > distance_threshold_down * 0.6)
        {
            new_state = hand_states.HANDS_MIDDLE;
        }
        else
        {
        }

        b1 = false;
    }
 // Update is called once per frame
 void Update()
 {
     UpdateThreshold();
     new_state = hand_states.HANDS_NEUTRAL;
     if (kmc.isTracked)
     {
         right_hand_position     = kmc.Hand_Right.transform.position;
         left_hand_position      = kmc.Hand_Left.transform.position;
         right_shoulder_position = kmc.Shoulder_Right.transform.position;
         left_shoulder_position  = kmc.Shoulder_Left.transform.position;
         distanceToBodyRight     = right_hand_position.y - right_shoulder_position.y;
         distanceToBodyLeft      = left_hand_position.y - left_shoulder_position.y;
         //à affiner selon le transform que l'on mettra
         //right_hand_position = kmc.transform.position;
         NewStateUpdate();
         StateTransition();
     }
     else
     {
         b1 = false;
     }
 }