Ejemplo n.º 1
0
        protected virtual void UpdateSkeleton()
        {
            if (skeletonAction == null)
            {
                return;
            }

            if (updatePose)
            {
                UpdatePose();
            }

            if (blendPoser != null && skeletonBlend < 1)
            {
                if (blendSnapshot == null)
                {
                    blendSnapshot = blendPoser.GetBlendedPose(this);
                }
                blendSnapshot = blendPoser.GetBlendedPose(this);
            }

            if (rangeOfMotionBlendRoutine == null)
            {
                if (temporaryRangeOfMotion != null)
                {
                    skeletonAction.SetRangeOfMotion(temporaryRangeOfMotion.Value);
                }
                else
                {
                    skeletonAction.SetRangeOfMotion(rangeOfMotion); //this may be a frame behind
                }
                UpdateSkeletonTransforms();
            }
        }
Ejemplo n.º 2
0
        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.");
                }
            }
        }