コード例 #1
0
    private void MoveLefttHand()
    {
        //Hand postion, thumb position
        LeapBonesLeft[2].GetComponent <Transform>().position  = ManusBonesLeft[0].GetComponent <Transform>().position;
        LeapBonesLeft[21].GetComponent <Transform>().position = ManusBonesLeft[23].GetComponent <Transform>().position;

        //Hand rotation
        LeapBonesLeft[2].GetComponent <Transform>().rotation =
            ManusBonesLeft[0].GetComponent <Transform>().rotation *Quaternion.Euler(180, 90, 90);


        //Arm Rotation and Pos

        LeapBonesLeft[3].transform.rotation = ManusBonesLeft[1].transform.rotation * Quaternion.Euler(0, -90, -90);
        LeapBonesLeft[3].transform.position =
            ManusBonesLeft[1].transform.position + _distL[5] * ManusBonesLeft[1].transform.up;

        for (var i = 0; i < 5; i++)
        {
            LeapBonesLeft[i + 4].transform.rotation =
                LeapBonesLeft[3].transform.rotation * Quaternion.Euler(-(i * 18), 0, 0);
            ;
            LeapBonesLeft[i + 4].transform.position =
                ManusBonesLeft[1].transform.position + _distL[4 - i] * ManusBonesLeft[1].transform.up;
        }

        //Finger Rotation
        for (var i = 0; i < 3; i++)
        {
            //Index
            LeapBonesLeft[i + 9].GetComponent <Transform>().rotation =
                ManusBonesLeft[i + 3].GetComponent <Transform>().rotation *Quaternion.Euler(-90, 180, 0);
            //Middle
            LeapBonesLeft[i + 12].GetComponent <Transform>().rotation =
                ManusBonesLeft[i + 8].GetComponent <Transform>().rotation *Quaternion.Euler(-90, 180, 0);
            //Pinky
            LeapBonesLeft[i + 15].GetComponent <Transform>().rotation =
                ManusBonesLeft[i + 13].GetComponent <Transform>().rotation *Quaternion.Euler(-90, 180, 0);
            //Ring
            LeapBonesLeft[i + 18].GetComponent <Transform>().rotation =
                ManusBonesLeft[i + 18].GetComponent <Transform>().rotation *Quaternion.Euler(-90, 180, 0);
            //Thumb
            LeapBonesLeft[i + 21].GetComponent <Transform>().rotation =
                ManusBonesLeft[i + 23].GetComponent <Transform>().rotation *Quaternion.Euler(0, 0, 180);
        }
        if (Variables.isTrialActive)
        {
            SaveHandPosition.Save(LeapBonesRight, SaveHandPosition.WhichHand.left);
        }
    }
コード例 #2
0
    private void map(GameObject[] leap, GameObject[] avatar)
    {
        //index, mid, pinky, ring, thumb
        int[] leap_index   = new int[] { 6, 10, 14, 18, 2 };
        int[] avatar_index = new int[] { 9, 12, 15, 18, 21 };


        switch (whichHand)
        {
        case Chirality.Left:

            avatar[2].transform.position = cHand.GetWristPosition();


            avatar[2].transform.rotation = leap[21].transform.rotation * Quaternion.Euler(palmRotLeft);     //palm


            //Loops over fingers to correct their rotation
            for (int i = 0; i < leap_index.Length; i++)
            {
                //loops over bones
                for (int j = 0; j < 3; j++)
                {
                    avatar[avatar_index[i] + j].transform.rotation =
                        leap[leap_index[i] + j].transform.rotation * Quaternion.Euler(fingerRotLeft);
                }
            }


            avatar[3].transform.position = cHand.GetElbowPosition();
            avatar[3].transform.rotation = leap[22].transform.rotation * Quaternion.Euler(armRotLeft);

            break;

        case Chirality.Right:

            avatar[2].transform.position = cHand.GetWristPosition();


            avatar[2].transform.rotation = leap[21].transform.rotation * Quaternion.Euler(palmRotRight);     //palm


            //Loops over fingers to correct their rotation
            for (int i = 0; i < leap_index.Length; i++)
            {
                //loops over bones
                for (int j = 0; j < 3; j++)
                {
                    avatar[avatar_index[i] + j].transform.rotation =
                        leap[leap_index[i] + j].transform.rotation * Quaternion.Euler(fingerRotRight);
                }
            }


            avatar[3].transform.position = cHand.GetElbowPosition();
            avatar[3].transform.rotation = leap[22].transform.rotation * Quaternion.Euler(armRotRight);

            break;
        }


        SaveHandPosition.Save(avatar[2].gameObject, avatar[0].GetComponent <PlayerHand>().whichHand, PV.ViewID);
    }