Ejemplo n.º 1
0
        void AddHandSkeletonBones(SkeletonBuilder skeletonBuilder, bool isLeftHand)
        {
            OVRSkeleton skeleton = isLeftHand ? _LeftHandOVRSkelton : _RightHandOVRSkelton;

            Dictionary <HumanBodyBones, OVRSkeleton.BoneId> handBoneIdMap;

            handBoneIdMap = isLeftHand ? _LeftHandBoneIdMap : _RightHandBoneIdMap;

            foreach (HumanBodyBones boneKey in handBoneIdMap.Keys)
            {
                OVRSkeleton.BoneId ovrBoneId = handBoneIdMap[boneKey];
                if ((int)ovrBoneId < skeleton.Bones.Count)
                {
                    Transform  skeletonBone  = skeleton.BindPoses[(int)ovrBoneId].Transform;
                    Vector3    localPosition = skeletonBone.localPosition;
                    Quaternion localRotation = skeletonBone.localRotation;

                    // Local pose composition
                    if ((ovrBoneId == OVRSkeleton.BoneId.Hand_Thumb2) || (ovrBoneId == OVRSkeleton.BoneId.Hand_Pinky1))
                    {
                        short     parentBoneIndex = skeleton.Bones[(int)ovrBoneId].ParentBoneIndex;
                        Transform parentBone      = skeleton.Bones[parentBoneIndex].Transform;
                        localPosition = parentBone.localPosition + parentBone.localRotation * localPosition;
                        localRotation = parentBone.localRotation * localRotation;
                    }

                    skeletonBuilder.Add(boneKey, _HandBoneParent[boneKey], localPosition, localRotation);
                }
            }
        }