This class manipulates the hand representation in the unity scene based on the input from the leap device. Fingers and Palm objects are moved around between higher level 'hand' objects that mainly serve to organize. Be aware that when fingers are lost, unity does not dispatch OnTriggerExit events.
Inheritance: MonoBehaviour
Beispiel #1
0
    /**
     * Use finger and controling from mouse if m_Use_mouse is true.
     */
    void UseMouseFinger()
    {
        LeapUnityHandController controller = GameObject.Find("Leap Hands").GetComponent <LeapUnityHandController>();

        finger = controller.m_fingers[0];
        controller.SetVisible(finger, true);
        controller.SetCollidable(finger, true);
    }
Beispiel #2
0
    private void CreateSceneHands()
    {
        GameObject hands = new GameObject("Leap Hands");

        if (m_InputParent)
        {
            hands.transform.parent = m_InputParent.transform;
        }
        else
        {
            hands.transform.parent = transform;
        }

        hands.AddComponent(typeof(LeapUnityHandController));
        LeapUnityHandController behavior = hands.GetComponent <LeapUnityHandController>();

        behavior.IsEnablingPalmRenderers           = this.IsEnablingPalmRenderers;
        behavior.IsEnablingFingerRenderers         = this.IsEnablingFingerRenderers;
        behavior.IsEnablingFingerChildrenRenderers = this.IsEnablingFingerChildrenRenderers;

        behavior.m_palms   = new GameObject[2];
        behavior.m_fingers = new GameObject[10];
        behavior.m_hands   = new GameObject[3];       //extra 'invalid' hand for grouping purposes

        for (int i = 0; i < behavior.m_hands.Length; i++)
        {
            behavior.m_hands[i] = CreateHand(hands, i);
        }
        for (int i = 0; i < behavior.m_fingers.Length; i++)
        {
            behavior.m_fingers[i] = CreateFinger(behavior.m_hands[2], i);
        }
        for (int i = 0; i < behavior.m_palms.Length; i++)
        {
            behavior.m_palms[i] = CreatePalm(behavior.m_hands[2], i);
        }

        foreach (GameObject fingerTip in GameObject.FindGameObjectsWithTag("FingerTip"))
        {
            fingerTip.AddComponent(typeof(LeapFingerCollisionDispatcher));
        }
    }
    private void CreateSceneHands()
    {
        GameObject hands = new GameObject("Leap Hands");

        if (m_InputParent)
        {
            hands.transform.parent = m_InputParent.transform;
        }
        else
        {
            hands.transform.parent = transform;
        }

        hands.AddComponent(typeof(LeapUnityHandController));
        LeapUnityHandController behavior = hands.GetComponent <LeapUnityHandController>();

        behavior.m_palms     = new GameObject[2];
        behavior.m_fingers   = new GameObject[10];
        behavior.m_hands     = new GameObject[3];     //extra 'invalid' hand for grouping purposes
        behavior.m_materials = new Material[] { m_PrimaryHandMaterial, m_SecondaryHandMaterial, m_UnknownHandMaterial };

        for (int i = 0; i < behavior.m_hands.Length; i++)
        {
            behavior.m_hands[i] = CreateHand(hands, i);
        }
        for (int i = 0; i < behavior.m_fingers.Length; i++)
        {
            behavior.m_fingers[i] = CreateFinger(behavior.m_hands[2], i);
        }
        for (int i = 0; i < behavior.m_palms.Length; i++)
        {
            behavior.m_palms[i] = CreatePalm(behavior.m_hands[2], i);
        }

        foreach (GameObject fingerTip in GameObject.FindGameObjectsWithTag("FingerTip"))
        {
            //Debug.Log ("adding component...");
            fingerTip.AddComponent(typeof(LeapFingerCollisionDispatcher));
        }
    }
    private void CreateSceneHands()
    {
        GameObject hands = new GameObject("Leap Hands");

        if( m_InputParent )
        {
            hands.transform.parent = m_InputParent.transform;
        }
        else
        {
            hands.transform.parent = transform;
        }

        hands.AddComponent(typeof(LeapUnityHandController));
        behavior = hands.GetComponent<LeapUnityHandController>();
        behavior.m_palms = new GameObject[2];
        behavior.m_fingers = new GameObject[10];
        behavior.m_hands = new GameObject[3]; //extra 'invalid' hand for grouping purposes
        tapped = behavior.gestureTapped;

        for( int i = 0; i < behavior.m_hands.Length; i++ )
        {
            behavior.m_hands[i] = CreateHand(hands, i);
        }
        for( int i = 0; i < behavior.m_fingers.Length; i++ )
        {
            behavior.m_fingers[i] = CreateFinger(behavior.m_hands[2], i);
        }
        for( int i = 0; i < behavior.m_palms.Length; i++ )
        {
            behavior.m_palms[i] = CreatePalm(behavior.m_hands[2], i);
        }

        foreach( GameObject fingerTip in GameObject.FindGameObjectsWithTag("FingerTip") )
        {
            fingerTip.AddComponent(typeof(LeapFingerCollisionDispatcher));
        }
    }