protected Vector3[] GetBonePositions() { if (skeletonAvailable) { Vector3[] rawSkeleton = skeletonAction.GetBonePositions(); if (mirroring == MirrorType.LeftToRight || mirroring == MirrorType.RightToLeft) { for (int boneIndex = 0; boneIndex < rawSkeleton.Length; boneIndex++) { rawSkeleton[boneIndex] = MirrorPosition(boneIndex, rawSkeleton[boneIndex]); } } return(rawSkeleton); } else { //fallback to getting skeleton pose from skeletonPoser if (fallbackPoser != null) { return(fallbackPoser.GetBlendedPose(skeletonAction, inputSource).bonePositions); } else { Debug.LogError("Skeleton Action is not bound, and you have not provided a fallback SkeletonPoser. Please create one to drive hand animation when no skeleton data is available.", this); return(null); } } }
protected void CopyBonePositions(Vector3[] positionBuffer) { if (skeletonAvailable) { Vector3[] rawSkeleton = skeletonAction.GetBonePositions(); if (mirroring == MirrorType.LeftToRight || mirroring == MirrorType.RightToLeft) { for (int boneIndex = 0; boneIndex < positionBuffer.Length; boneIndex++) { MirrorBonePosition(ref rawSkeleton[boneIndex], ref positionBuffer[boneIndex], boneIndex); } } else { rawSkeleton.CopyTo(positionBuffer, 0); } } else { //fallback to getting skeleton pose from skeletonPoser if (fallbackPoser != null) { fallbackPoser.GetBlendedPose(skeletonAction, inputSource).bonePositions.CopyTo(positionBuffer, 0); } else { Debug.LogError("Skeleton Action is not bound, and you have not provided a fallback SkeletonPoser. Please create one to drive hand animation when no skeleton data is available."); } } }
protected Vector3[] GetBonePositions(SteamVR_Input_Sources inputSource) { Vector3[] rawSkeleton = skeletonAction.GetBonePositions(inputSource); if (mirroring == MirrorType.LeftToRight || mirroring == MirrorType.RightToLeft) { for (int boneIndex = 0; boneIndex < rawSkeleton.Length; boneIndex++) { if (boneIndex == SteamVR_Skeleton_JointIndexes.wrist || IsMetacarpal(boneIndex)) { rawSkeleton[boneIndex].Scale(new Vector3(-1, 1, 1)); } else if (boneIndex != SteamVR_Skeleton_JointIndexes.root) { rawSkeleton[boneIndex] = rawSkeleton[boneIndex] * -1; } } } return(rawSkeleton); }