コード例 #1
0
        /// <summary>
        /// Plays the animation from start.
        /// </summary>
        protected override void OnStarted()
        {
            blendTimer = 0;

            if (BlendEnabled && Skeleton.HasAnimated)
            {
                ValidateBlendTarget();
                if (blendTarget == null || blendTarget.Length < Skeleton.BoneTransforms.Length)
                {
                    blendTarget = new Matrix[Skeleton.BoneTransforms.Length];
                }
                Skeleton.CopyBoneTransformsTo(blendTarget);
            }
            Skeleton.HasAnimated = true;

            if (Controllers.Count > 0 && weightedBones == null || numControllers < Controllers.Count ||
                numBones < Skeleton.BoneTransforms.Length)
            {
                numControllers = Math.Max(numControllers, Controllers.Count);
                numBones       = Math.Max(numBones, Skeleton.BoneTransforms.Length);

                weightedBones = new BoneAnimationItem[numControllers * numBones];
            }

            SychronizeSpeed();

            foreach (IBoneAnimationController controller in Controllers)
            {
                IAnimation animation = controller as IAnimation;
                if (animation != null)
                {
                    animation.OnStarted();
                }
            }

            // Refresh the pose immediately so the skin transform is correct even if update is never called.
            UpdateBoneTransforms(0);

            base.OnStarted();
        }