Exemplo n.º 1
0
        public void ProcessAnimation(AnimationStream stream)
        {
            AnimationStream inputStream = stream.GetInputStream(0);

            if (BlendActive)
            {
                for (int i = 0; i < TargetAnimationTransforms.Length; ++i)
                {
                    TransformStreamHandle TargetTransform   = TargetAnimationTransforms[i];
                    TransformSceneHandle  CurrentTransform  = CurrentAnimationTransforms[i];
                    TransformData         PreviousTransform = PreviousAnimationTransforms[i];

                    float3 currentPos = float3.zero;
                    if (i == 0)
                    {
                        float3 targetPos = TargetTransform.GetLocalPosition(inputStream);
                        currentPos = CurrentTransform.GetLocalPosition(stream);

                        float3 pos = Inertialize(PreviousTransform.Position,
                                                 currentPos, targetPos, DeltaTime, RemainingTime, DeltaTime);

                        TargetTransform.SetLocalPosition(stream, pos);
                    }

                    quaternion targetRot  = TargetTransform.GetLocalRotation(inputStream);
                    quaternion currentRot = CurrentTransform.GetLocalRotation(stream);

                    quaternion rot = Inertialize(PreviousTransform.Rotation,
                                                 currentRot, targetRot, DeltaTime, RemainingTime, DeltaTime);

                    TargetTransform.SetLocalRotation(stream, rot);

                    PreviousAnimationTransforms[i] = new TransformData(currentPos,
                                                                       currentRot);
                }
            }
            else
            {
                for (int i = 0; i < TargetAnimationTransforms.Length; ++i)
                {
                    TransformStreamHandle TargetTransform  = TargetAnimationTransforms[i];
                    TransformSceneHandle  CurrentTransform = CurrentAnimationTransforms[i];

                    if (i == 0)
                    {
                        TargetTransform.SetLocalPosition(stream, TargetTransform.GetLocalPosition(inputStream));
                    }

                    TargetTransform.SetLocalRotation(stream, TargetTransform.GetLocalRotation(inputStream));

                    PreviousAnimationTransforms[i] = new TransformData(CurrentTransform.GetLocalPosition(stream),
                                                                       CurrentTransform.GetLocalRotation(stream));
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Gets the rotation of the transform relative to the parent.
 /// </summary>
 /// <param name="stream">The AnimationStream that holds the animated values.</param>
 /// <returns>The rotation of the transform relative to the parent.</returns>
 public Quaternion GetLocalRotation(AnimationStream stream) =>
 m_InStream == 1 ? m_StreamHandle.GetLocalRotation(stream) : m_SceneHandle.GetLocalRotation(stream);