Пример #1
0
    // Use this for initialization
    void Start()
    {
        // Creates the App Finger objects for tracking fingers
        m_appFingers = new AppFinger[10];
        for (int i = 0; i < m_appFingers.Length; i++)
        {
            m_appFingers[i] = new AppFinger();
            m_appFingers[i].M_FingerObject = m_FingerObject;
            m_appFingers[i].initialize();
        }

        // Creates the app Hand objects for tracking hands
        m_appHands = new AppHand[2];
        for (int i = 0; i < m_appHands.Length; i++)
        {
            // Instantiates the object to represent the palms
            GameObject palmObject = (GameObject)Instantiate(m_PalmObject, Vector3.zero, Quaternion.identity);
            palmObject.transform.parent        = transform;
            palmObject.transform.localPosition = Vector3.zero;

            m_appHands[i] = new AppHand();
            m_appHands[i].M_HandPalmObject = palmObject;
            m_appHands[i].initialize();
        }
    }
Пример #2
0
    /// <summary>
    /// Raises the hand found event.
    /// </summary>
    /// <param name='h'>
    /// H.
    /// </param>
    public void OnHandFound(Hand h)
    {
        // Tries to find the current hand id
        AppHand hand = findHand(h.Id);

        // Checks if it finds the hand
        if (hand != null)
        {
            // Updates the hand
            updateHandValues(hand, h);
        }
        else
        {
            // Searches for an available hand
            int index = findAvailableHand();

            if (index != -1)
            {
                // Initialize a New Hand
                hand = m_appHands[index];
                hand.initialize();
                hand.M_id = h.Id;

                // Updates the hand
                updateHandValues(hand, h);
            }
        }
    }
Пример #3
0
 private void updateHandValues(AppHand hand, Hand h)
 {
     hand.M_DataWeight       = (Mathf.Min(hand.M_DataWeight + m_DataWeightSmooth * Time.deltaTime, 1.0f));
     hand.M_HandDirection    = h.Direction.ToUnity() * hand.M_DataWeight;
     hand.M_HandPosition     = h.PalmPosition.ToUnity() * hand.M_DataWeight;
     hand.M_SmoothedPosition = (hand.M_SmoothedPosition + m_SmoothFactor * (hand.M_HandPosition - hand.M_SmoothedPosition));
     hand.M_Tracked          = true;
 }
Пример #4
0
    /// <summary>
    /// Raises the hand lost event.
    /// </summary>
    /// <param name='lostID'>
    /// Lost I.
    /// </param>
    public void OnHandLost(int lostID)
    {
        AppHand hand = findHand(lostID);

        if (hand != null)
        {
            //hand.M_Tracked = false;
            hand.initialize();
        }
    }
Пример #5
0
    /// <summary>
    /// Raises the hand updated event.
    /// </summary>
    /// <param name='h'>
    /// H.
    /// </param>
    public void OnHandUpdated(Hand h)
    {
        AppHand hand = findHand(h.Id);

        // Checks if it finds the hand
        if (hand != null)
        {
            updateHandValues(hand, h);
        }
    }