Ejemplo n.º 1
0
 /// <summary>
 /// Interpolate between the two given DbTransforms with the given weight.
 /// </summary>
 /// <param name="t1">The first transform</param>
 /// <param name="t2">The second transform</param>
 /// <param name="weight">Value between 0 and 1</param>
 /// <returns>The interpolated DbTransform</returns>
 public static DbTransform Interpolate(DbTransform t1, DbTransform t2, float weight)
 {
     return(new DbTransform(
                Vector2.Lerp(t1.Translation, t2.Translation, weight),
                Quaternion.Slerp(t1.Rotation, t2.Rotation, weight),
                Vector2.Lerp(t1.Scale, t2.Scale, weight)));
 }
Ejemplo n.º 2
0
 public static DbTransform Combine(DbTransform t1, DbTransform t2)
 {
     return(new DbTransform(
                t1.Translation + t2.Translation,
                t1.Rotation * t2.Rotation,
                t1.Scale * t2.Scale));
 }
Ejemplo n.º 3
0
 internal DbBone(DbArmature armature, BoneData data) : base(data.Name, armature, data.Parent)
 {
     Origin = new DbTransform(data.Transform);
     _tween = DbTransform.Identity;
     CurrentGlobalTransform = Origin.GetMatrix();
     Length = data.Length;
     Bones  = new List <DbBone>();
     Slots  = new List <DbSlot>();
 }
Ejemplo n.º 4
0
        internal void ResetRecursive()
        {
            _tween = DbTransform.Identity;
            var parentTransform = Parent?.CurrentGlobalTransform ?? Matrix.Identity;

            CurrentGlobalTransform = Origin.GetMatrix() * parentTransform;
            foreach (var child in Bones)
            {
                child.ResetRecursive();
            }
        }
Ejemplo n.º 5
0
        // TODO: remove slots/bones

        internal void UpdateRecursive(TransformTimelineState state)
        {
            var parentTransform = Parent?.CurrentGlobalTransform ?? Matrix.Identity;

            // get the current tween transform
            _tween = state.GetState(Name);

            // and update the current transform
            CurrentGlobalTransform = DbTransform.Combine(Origin, _tween).GetMatrix() *
                                     parentTransform;

            // and all children
            foreach (var child in Bones)
            {
                child.UpdateRecursive(state);
            }
        }