Пример #1
0
    /*
     * Returns whether a hand is "just opened" or "just closed" from a state of closed or opened hand
     *
     * Called by JustOpenedHandOn  or JustClosedHandOn
     * @param hand: LeapMotion Hand Model
     * @param handId: HandUtil.LEFT(=0) or HandUtil.RIGHT(=1)
     * @param actionType: Hand just opened action or Hand just closed action
     * @return whether the action is started (true or false)
     */
    private bool JustActionedHandOn(Hand[] hands, int handId, HandActionType actionType)
    {
        Hand hand = hands[handId];

        //過去手を開いていて,現在の手が存在し,その手の指が全部閉じるとき
        if (hand != null)
        {
            switch (actionType)
            {
            case HandActionType.JUST_OPENED:
                //Whether the hand is just opened
                if (!this.isOpenedPreviousHands[handId] && HandUtil.GetHandStatus(hand) == HandStatus.OPEN)
                {
                    this.isOpenedPreviousHands[handId] = true; //hand status
                    return(true);                              //Just opened
                }
                break;

            case HandActionType.JUST_CLOSED:
                //Whether the hand is just closed
                if (this.isOpenedPreviousHands[handId] && HandUtil.GetHandStatus(hand) == HandStatus.CLOSE)
                {
                    this.isOpenedPreviousHands[handId] = false; //hand status
                    return(true);                               //Just closed
                }
                break;
            }
        }
        return(false); //Not Actioned
    }
Пример #2
0
 /*
  * Save whether your previous hands are opened
  * THIS IS USED FOR JustOpenedHandOn() & JustClosedHandOn()
  * @param hands Leap.Hand[] both hands
  */
 public void SavePreviousHands(Hand[] hands)
 {
     foreach (int handId in this.handIds)
     {
         Hand hand = hands[handId];
         if (hand == null)
         {
             this.existsPreviousHands[handId] = false;
         }
         else
         {
             this.existsPreviousHands[handId] = true;
             if (HandUtil.GetHandStatus(hand) == HandStatus.OPEN)
             {
                 this.isOpenedPreviousHands[handId] = true;
             }
             else if (HandUtil.GetHandStatus(hand) == HandStatus.CLOSE)
             {
                 this.isOpenedPreviousHands[handId] = false;
             }
             else
             {
             }        //何も保存しない
         }
     }
     //Debug.Log("Left: " + this.isOpenedPreviousHands[HandUtil.LEFT]);
     //Debug.Log("Right: " + this.isOpenedPreviousHands[HandUtil.RIGHT]);
 }