public void SetSecondaryAnimation(SkinnedModelAnimation animation, GameTime gameTime) // = null
        {
            /*PreviousAnimation = animation;
             * PreviousBoneAnimationInstances.Clear();
             * PreviousBoneAnimationInstances.AddRange(BoneAnimationInstances);*/
            if (animation != null)
            {
                SecondaryAnimation = animation;

                SecondaryBoneAnimationInstances.Clear();
                foreach (var boneAnimation in animation.BoneAnimations)
                {
                    BoneAnimationInstance boneAnimationInstance = new BoneAnimationInstance();
                    boneAnimationInstance.BoneAnimation       = boneAnimation;
                    boneAnimationInstance.Updated             = false;
                    boneAnimationInstance.AdditionalTransform = Matrix.Identity;
                    //boneAnimationInstance.PreviousBoneAnimationInstance = PreviousBoneAnimationInstances.FirstOrDefault(ni => ni.BoneAnimation.Name == boneAnimation.Name);
                    SecondaryBoneAnimationInstances.Add(boneAnimationInstance);
                }

                foreach (var boneAnimationInstance in SecondaryBoneAnimationInstances)
                {
                    boneAnimationInstance.Parent = SecondaryBoneAnimationInstances.FirstOrDefault(ni => ni.BoneAnimation == boneAnimationInstance.BoneAnimation.Parent);
                }

                foreach (var meshInstance in MeshInstances)
                {
                    //meshInstance.BoneInstances.Clear();
                    for (int i = 0; i < meshInstance.BoneInstances.Count; i++)//foreach (var boneInstance in meshInstance.BoneInstances)
                    {
                        var boneInstance = meshInstance.BoneInstances[i];
                        var bone         = meshInstance.Mesh.Bones[i];
                        boneInstance.SecondaryBoneAnimationInstance = SecondaryBoneAnimationInstances.FirstOrDefault(ni => ni.BoneAnimation.Name == bone.Name);
                        meshInstance.BoneInstances[i] = boneInstance;
                    }
                }
            }
            else
            {
                SecondaryBoneAnimationInstances.Clear();

                foreach (var boneAnimationInstance in SecondaryBoneAnimationInstances)
                {
                    boneAnimationInstance.Parent = SecondaryBoneAnimationInstances.FirstOrDefault(ni => ni.BoneAnimation == boneAnimationInstance.BoneAnimation.Parent);
                }

                foreach (var meshInstance in MeshInstances)
                {
                    //meshInstance.BoneInstances.Clear();
                    for (int i = 0; i < meshInstance.BoneInstances.Count; i++)//foreach (var boneInstance in meshInstance.BoneInstances)
                    {
                        var boneInstance = meshInstance.BoneInstances[i];
                        boneInstance.SecondaryBoneAnimationInstance = null;
                        meshInstance.BoneInstances[i] = boneInstance;
                    }
                }
            }
        }
        public void SetAnimation(SkinnedModelAnimation animation, GameTime gameTime) // = null
        {
            if (gameTime != null)
            {
                TimeAnimationChanged = gameTime.TotalGameTime;
                //Debug.Print(TimeAnimationChanged.ToString());
            }

            PreviousAnimation = animation;
            PreviousBoneAnimationInstances.Clear();
            PreviousBoneAnimationInstances.AddRange(BoneAnimationInstances);

            Animation = animation;

            BoneAnimationInstances.Clear();
            foreach (var boneAnimation in animation.BoneAnimations)
            {
                BoneAnimationInstance boneAnimationInstance = new BoneAnimationInstance();
                boneAnimationInstance.BoneAnimation                 = boneAnimation;
                boneAnimationInstance.Updated                       = false;
                boneAnimationInstance.AdditionalTransform           = Matrix.Identity;
                boneAnimationInstance.PreviousBoneAnimationInstance = PreviousBoneAnimationInstances.FirstOrDefault(ni => ni.BoneAnimation.Name == boneAnimation.Name);
                BoneAnimationInstances.Add(boneAnimationInstance);
            }

            foreach (var boneAnimationInstance in BoneAnimationInstances)
            {
                boneAnimationInstance.Parent = BoneAnimationInstances.FirstOrDefault(ni => ni.BoneAnimation == boneAnimationInstance.BoneAnimation.Parent);
            }

            foreach (var meshInstance in MeshInstances)
            {
                meshInstance.BoneInstances.Clear();
                foreach (var bone in meshInstance.Mesh.Bones)
                {
                    var boneInstance = new BoneInstance();
                    boneInstance.Bone = bone;
                    boneInstance.BoneAnimationInstance = BoneAnimationInstances.FirstOrDefault(ni => ni.BoneAnimation.Name == bone.Name);
                    meshInstance.BoneInstances.Add(boneInstance);
                }
            }
        }