Exemplo n.º 1
0
        public override Matrix[] GetBoneTransforms()
        {
            // Pick an arbitrary node to 'prime' the refinement loop
            float lowerBoundPosition = ChildrenByPosition.Keys.Min();
            float upperBoundPosition = ChildrenByPosition.Keys.Max();

            foreach (float position in ChildrenByPosition.Keys)
            {
                if (position > lowerBoundPosition && position <= BlendPosition)
                {
                    lowerBoundPosition = position;
                }

                if (position < upperBoundPosition && position >= BlendPosition)
                {
                    upperBoundPosition = position;
                }
            }

            Matrix[] lowerBoundTransforms = ChildrenByPosition[lowerBoundPosition].GetBoneTransforms();

            if (lowerBoundPosition == upperBoundPosition)
            {
                return(lowerBoundTransforms);
            }

            Matrix[] upperBoundTransforms = ChildrenByPosition[upperBoundPosition].GetBoneTransforms();
            float    blendFactor          = (BlendPosition - lowerBoundPosition) /
                                            (upperBoundPosition - lowerBoundPosition);

            return(SpaceUtils.LerpSkeletalPose(lowerBoundTransforms, upperBoundTransforms, blendFactor));
        }
Exemplo n.º 2
0
        public Matrix[] GetSkinTransforms()
        {
            Matrix[] blendStartPose;

            if (blendFromCancelledTransitionPose)
            {
                blendStartPose = cancelledPose;
            }
            else
            {
                blendStartPose = CurrentState.GetBoneTransforms();
            }

            if (ActiveTransition == null)
            {
                return(CreateSkinTransforms(blendStartPose));
            }
            else
            {
                Matrix[] nextStatePose = nextState.GetBoneTransforms();

                float pctComplete = (float)(transitionTime.TotalSeconds / ActiveTransition.DurationInSeconds);
                float blendFactor = ActiveTransition.UseSmoothStep ? MathHelper.SmoothStep(0.0f, 1.0f, pctComplete) : pctComplete;

                Matrix[] blendedPose = SpaceUtils.LerpSkeletalPose(blendStartPose, nextStatePose, blendFactor);

                // Store the blended pose in case we have to cancel the transition next frame.
                if (!blendFromCancelledTransitionPose)
                {
                    cancelledPose = blendedPose;
                }

                return(CreateSkinTransforms(blendedPose));
            }
        }
Exemplo n.º 3
0
        public override Matrix[] GetBoneTransforms()
        {
            Matrix[] child1Transforms = child1.GetBoneTransforms();
            Matrix[] child2Transforms = child2.GetBoneTransforms();

            return(SpaceUtils.LerpSkeletalPose(child1Transforms, child2Transforms, BlendFactor));
        }