예제 #1
0
    private void UpdateFingerBonesPositions()
    {
        //Set position of spheres to the same as bone_positions
        for (int i = 0; i < NUM_FINGERS; i++)
        {
            for (int g = 1; g < NUM_BONES; g++)
            {
                finger_bone_positions[i, g] = manager.GetBoneCenterWorldPosition(i, g);

                //Add parents offset to finger_bone_positions
                //AddOffsetFromParent(i, g);

                //Set position of game sphere
                finger_bones [i, g].GetComponent <BoneManager>().targetPosition = finger_bone_positions[i, g];
            }
        }
    }
예제 #2
0
    private void UpdateBonePositions()
    {
        //For core
        corePosition = leapManager.GetPalmWorldPosition();
        core.GetComponent <CoreManager>().targetPosition = corePosition;

        //For palm
        for (int i = 0; i < palmBoneCount; i++)
        {
            //Scale all offsets, based on grib strength
            //---

            //Update stored positions/rotations
            palmBoneRotations [i] = leapManager.GetPalmRotation() /** Quaternion.Euler(Vector3.up * 180) * Quaternion.Euler(Vector3.forward * 180)*/;             //EXTEND HERE, TO ACCOMODATE MORE PALMBONES!
            //palmBonePositions [i] = manager.GetPalmWorldPosition () +palmBoneOffsets [i];

            Vector3 newOffset = -palmBoneOffsets [i];
            newOffset             = Quaternion.Euler(leapManager.GetPalmRotation().eulerAngles) * newOffset;
            palmBonePositions [i] = leapManager.GetPalmWorldPosition() + newOffset * fingerBoneScale * 0.75f;

            //Update bones
            palm_bones [i].GetComponent <BoneManager>().targetPosition = palmBonePositions[i];
            palm_bones [i].GetComponent <BoneManager>().targetRotation = palmBoneRotations[i];
        }

        //For fingers
        for (int i = 0; i < fingerCount; i++)
        {
            for (int j = 0; j < fingerBoneCount; j++)
            {
                //Treat positions differently, depending on if it's thumb or some other finger
                switch (i)
                {
                case 0:                 //Thumb
                    switch (j)
                    {
                    case 0:
                        fingerBonePositions [i, j] = leapManager.GetBoneCenterWorldPosition(i, 1); break;

                    case 1:
                        fingerBonePositions [i, j] = leapManager.GetBoneBaseWorldPosition(i, 2); break;

                    case 2:
                        fingerBonePositions [i, j] = leapManager.GetBoneCenterWorldPosition(i, 2); break;

                    case 3:
                        fingerBonePositions [i, j] = leapManager.GetBoneBaseWorldPosition(i, 3); break;
                    }
                    break;

                default:                 //Other fingers
                    //Update stored positions/rotations
                    fingerBonePositions [i, j] = leapManager.GetBoneCenterWorldPosition(i, j);
                    break;
                }

                fingerBoneRotations [i, j] = leapManager.GetBoneRotation(i, j);

                //Update bones
                finger_bones [i, j].GetComponent <BoneManager>().targetPosition = fingerBonePositions[i, j];
                finger_bones [i, j].GetComponent <BoneManager>().targetRotation = fingerBoneRotations[i, j];
            }
        }
    }