/// <summary>
        /// Recursively updates all the children of a node.
        /// </summary>
        /// <param name="srcA">Source skeleton node for the current frame.</param>
        /// <param name="srcB">Source skeleton node for the next frame.</param>
        /// <param name="srcP">Parent skeleton node (use null if theres no parent).</param>
        /// <param name="dest">Destination skeleton node to have the two sources applied to.</param>
        /// <param name="framePercent">A value between 0.0 and 1.0 stating how far along the animation is
        /// from the current frame.</param>
        void RecursiveUpdate(SkeletonNode srcA, SkeletonNode srcB, SkeletonNode srcP, SkeletonNode dest, float framePercent)
        {
            // Set the position
            Vector2 vA;
            Vector2 vB;

            if (_scale == 1.0f)
            {
                vA = srcA.Position;
                vB = srcB.Position;
            }
            else
            {
                vA = srcA.Position * _scale;
                vB = srcB.Position * _scale;
            }
            dest.Position = Vector2.Lerp(vA, vB, framePercent);

            // Check if the node is part of a modifier animation
            if (srcP == null)
            {
                // Set the length
                dest.SetLength(srcA.GetLength() * _scale);
            }
            else
            {
                // This is a modifier so check for inheriting node values
                dest.SetLength(srcP.GetLength());
                if (!srcP.IsModifier && srcP.Parent != null)
                {
                    dest.SetAngle(srcP.GetAngle());
                }
            }

            // Update the child nodes (if there is any)
            for (var i = 0; i < srcA.internalNodes.Count; i++)
            {
                var nextSrcP = (srcP == null ? null : srcP.internalNodes[i]);
                RecursiveUpdate(srcA.internalNodes[i], srcB.internalNodes[i], nextSrcP, dest.internalNodes[i], framePercent);
            }
        }
Example #2
0
        /// <summary>
        /// Recursively copies the length of one set of nodes to another set of nodes
        /// </summary>
        /// <param name="src">Source root SkeletonNode to copy from</param>
        /// <param name="dest">Destination root SkeletonNode to copy to</param>
        public static void CopyLength(SkeletonNode src, SkeletonNode dest)
        {
            if (src == null)
            {
                Debug.Fail("src is null.");
                return;
            }
            if (dest == null)
            {
                Debug.Fail("dest is null.");
                return;
            }

            dest.SetLength(src.GetLength());
            for (var i = 0; i < src.Nodes.Count(); i++)
            {
                CopyLength(src.Nodes.ElementAt(i), dest.Nodes.ElementAt(i));
            }
        }
Example #3
0
        /// <summary>
        /// Recursively copies the length of one set of nodes to another set of nodes
        /// </summary>
        /// <param name="src">Source root SkeletonNode to copy from</param>
        /// <param name="dest">Destination root SkeletonNode to copy to</param>
        public static void CopyLength(SkeletonNode src, SkeletonNode dest)
        {
            if (src == null)
            {
                Debug.Fail("src is null.");
                return;
            }
            if (dest == null)
            {
                Debug.Fail("dest is null.");
                return;
            }

            dest.SetLength(src.GetLength());
            for (var i = 0; i < src.Nodes.Count(); i++)
            {
                CopyLength(src.Nodes.ElementAt(i), dest.Nodes.ElementAt(i));
            }
        }
Example #4
0
        /// <summary>
        /// Recursively updates all the children of a node.
        /// </summary>
        /// <param name="srcA">Source skeleton node for the current frame.</param>
        /// <param name="srcB">Source skeleton node for the next frame.</param>
        /// <param name="srcP">Parent skeleton node (use null if theres no parent).</param>
        /// <param name="dest">Destination skeleton node to have the two sources applied to.</param>
        /// <param name="framePercent">A value between 0.0 and 1.0 stating how far along the animation is
        /// from the current frame.</param>
        void RecursiveUpdate(SkeletonNode srcA, SkeletonNode srcB, SkeletonNode srcP, SkeletonNode dest, float framePercent)
        {
            // Set the position
            Vector2 vA;
            Vector2 vB;
            if (_scale == 1.0f)
            {
                vA = srcA.Position;
                vB = srcB.Position;
            }
            else
            {
                vA = srcA.Position * _scale;
                vB = srcB.Position * _scale;
            }
            dest.Position = Vector2.Lerp(vA, vB, framePercent);

            // Check if the node is part of a modifier animation
            if (srcP == null)
            {
                // Set the length
                dest.SetLength(srcA.GetLength() * _scale);
            }
            else
            {
                // This is a modifier so check for inheriting node values
                dest.SetLength(srcP.GetLength());
                if (!srcP.IsModifier && srcP.Parent != null)
                    dest.SetAngle(srcP.GetAngle());
            }

            // Update the child nodes (if there is any)
            for (var i = 0; i < srcA.internalNodes.Count; i++)
            {
                var nextSrcP = (srcP == null ? null : srcP.internalNodes[i]);
                RecursiveUpdate(srcA.internalNodes[i], srcB.internalNodes[i], nextSrcP, dest.internalNodes[i], framePercent);
            }
        }