Ejemplo n.º 1
0
 //--------------------------------------------------------------------------------------------------
 // Fix Data 的函数
 static public bool CheckHandsData(HandPair hands, HandPair LastHands, bool m_OpenFixeFrameData)
 {
     // Check hands are empty to decide fix or hold on all interaction
     if (hands.empty)
     {
         if (m_OpenFixeFrameData)
         {
             //---------------------------
             // fix current hand
             if (!LastHands.empty)
             {
                 FixCurrentHand(hands, LastHands);
                 return(true);
             }
             else
             {
                 return(false);
             }
             //---------------------------
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(true);
     }
 }
    void Start()
    {
        // Init Hands
        hands_       = new HandPair();
        hands_.L     = new Hand();
        hands_.R     = new Hand();
        hands_.empty = true;

        // Init EventType
        lastEventType_    = IEventType.NoAction;
        currentEventType_ = IEventType.NoAction;
    }
Ejemplo n.º 3
0
    // 检查两手相向移动
    static public bool CheckHandsMoveCross(HandPair hands, HandPair LastHands)
    {
        if (hands.empty)
        {
            Debug.Log("There may exist an error or this is a pair fixed hands");
        }

        float PalmDistance     = hands.L.PalmPosition.DistanceTo(hands.R.PalmPosition);
        float LastPalmDistance = LastHands.L.PalmPosition.DistanceTo(LastHands.R.PalmPosition);

        return(LastPalmDistance - PalmDistance > HandsCoressThreshold ? true : false);
    }
Ejemplo n.º 4
0
    public void DoCurrentEvent(IEventType CurrentEventType, IEventType LastEventType, HandPair hands,
                               HitBall m_ControllBall_L, HitBall m_ControllBall_R)
    {
        // Check hands are empty to decide fix or hold on all interaction
        //if (!GMS.CheckHandsData(hands, LastHands, m_OpenFixeFrameData)) return;

        switch (CurrentEventType)
        {
        case IEventType.NoAction:
            return;

            break;

        case IEventType.CancelAction:
            if (LastEventType != IEventType.NoAction)
            {
                if (LastEventType == IEventType.Navigation_RayHit)
                {
                    Action_Navigation_HitRay(hands.R, m_ControllBall_R, IFuncType.Close);
                }

                if (LastEventType == IEventType.Selection_Single)
                {
                    Action_Selection_Single(hands.R, m_ControllBall_R, IFuncType.Close);
                }
            }
            break;

        case IEventType.Navigation_RayHit:
            if (LastEventType != CurrentEventType)
            {
                Action_Navigation_HitRay(hands.R, m_ControllBall_R, IFuncType.Init);
            }
            else
            {
                Action_Navigation_HitRay(hands.R, m_ControllBall_R, IFuncType.Update);
            }
            break;

        case IEventType.Selection_Single:
            if (LastEventType != CurrentEventType)
            {
                Action_Selection_Single(hands.R, m_ControllBall_R, IFuncType.Init);
            }
            else
            {
                Action_Selection_Single(hands.R, m_ControllBall_R, IFuncType.Update);
            }
            break;

        case IEventType.Manipulation_Rotation:
            if (LastEventType != CurrentEventType)
            {
                Action_Manipulation_Rotation(hands.L, m_ControllBall_L, IFuncType.Init);
            }
            else
            {
                Action_Manipulation_Rotation(hands.L, m_ControllBall_L, IFuncType.Update);
            }
            break;

        default:
            break;
        }
    }
Ejemplo n.º 5
0
    public void CheckCurrentEvent(IEventType CurrentEventType, IEventType LastEventType, HandPair hands,
                                  HitBall m_ControllBall_L, HitBall m_ControllBall_R)
    {
        switch (CurrentEventType)
        {
        case IEventType.NoAction:
            break;

        case IEventType.Navigation_RayHit:
            if (LastEventType == CurrentEventType)
            {
                CurrentEventType = m_ControllBall_R.radius < 0.15 ?
                                   IEventType.Navigation_RayHit : IEventType.Selection_Single;
            }
            break;

        case IEventType.Selection_Single:
            if (LastEventType == CurrentEventType)
            {
                CurrentEventType = m_ControllBall_R.radius < 0.15 ?
                                   IEventType.Navigation_RayHit : IEventType.Selection_Single;
            }
            break;

        case IEventType.Manipulation_Rotation:
            if (LastEventType == CurrentEventType)
            {
                CurrentEventType = m_ControllBall_L.radius < 0.15 ?
                                   IEventType.Manipulation_Rotation : IEventType.Manipulation_Stroll;
            }
            break;

        case IEventType.Manipulation_Stroll:
            if (LastEventType == CurrentEventType)
            {
                CurrentEventType = m_ControllBall_L.radius < 0.15 ?
                                   IEventType.Manipulation_Rotation : IEventType.Manipulation_Stroll;
            }
            break;

        default:
            break;
        }
    }
Ejemplo n.º 6
0
    // 手握拳

    // 双手握拳
    static public bool CheckHandsAllFist(HandPair hands)
    {
        return(CheckHandFist(hands.L) && CheckHandFist(hands.R) ? true : false);
    }
Ejemplo n.º 7
0
 // 双手打开
 static public bool CheckTwoHandsRelaxed(HandPair hands)
 {
     return(!CheckHandFist(hands.L) && !CheckHandFist(hands.R) ? true : false);
 }
Ejemplo n.º 8
0
 // if there occurs that emtpy hand while last time have hands, Fix hands with this function
 static private void FixCurrentHand(HandPair hands, HandPair LastHands)
 {
     hands.empty = false;
     hands.L.CopyFrom(LastHands.L);
     hands.R.CopyFrom(LastHands.R);
 }