public BoneInfo(AnimationClip.Bone bone, AnimationPlayer player)
            {
                this.ClipBone = bone;
                Player = player;

                SetKeyframes();
                SetPosition(0);
            }
        void InitAnimations()
        {
            InitBones();


            Debug.Assert(TestCharacterBoneDefinitions(), "Warning! Bone definitions in model " + this.ModelName + " are incorrect.");

            m_helperMatrix = Matrix.CreateRotationY((float)Math.PI);
            
            m_player = new AnimationPlayer();
            m_playerNextAnim = new AnimationPlayer();

            string[] bones = null;
            m_characterDefinition.BoneSets.TryGetValue("Head", out bones);
            m_headPlayer = new MyAnimationPlayerBlendPair(this, bones);

            bones = null;
            m_characterDefinition.BoneSets.TryGetValue("Spine", out bones);
            m_spinePlayer = new MyAnimationPlayerBlendPair(this, bones);

            bones = null;
            m_characterDefinition.BoneSets.TryGetValue("LeftHand", out bones);
            m_leftHandPlayer = new MyAnimationPlayerBlendPair(this, bones);

            bones = null;
            m_characterDefinition.BoneSets.TryGetValue("RightHand", out bones);
            m_rightHandPlayer = new MyAnimationPlayerBlendPair(this, bones);

            bones = null;
            m_characterDefinition.BoneSets.TryGetValue("LeftFingers", out bones);
            m_leftFingersPlayer = new MyAnimationPlayerBlendPair(this, bones);

            bones = null;
            m_characterDefinition.BoneSets.TryGetValue("RightFingers", out bones);
            m_rightFingersPlayer = new MyAnimationPlayerBlendPair(this, bones);

            FindBone(m_characterDefinition.HeadBone, out m_headBoneIndex);
            FindBone(m_characterDefinition.Camera3rdBone, out m_camera3rdBoneIndex);
            if (m_camera3rdBoneIndex == -1)
                m_camera3rdBoneIndex = m_headBoneIndex;            
            FindBone(m_characterDefinition.LeftHandIKStartBone, out m_leftHandIKStartBone);
            FindBone(m_characterDefinition.LeftHandIKEndBone, out m_leftHandIKEndBone);
            FindBone(m_characterDefinition.RightHandIKStartBone, out m_rightHandIKStartBone);
            FindBone(m_characterDefinition.RightHandIKEndBone, out m_rightHandIKEndBone);

            FindBone(m_characterDefinition.LeftUpperarmBone, out m_leftUpperarmBone);
            FindBone(m_characterDefinition.LeftForearmBone, out m_leftForearmBone);
            FindBone(m_characterDefinition.RightUpperarmBone, out m_rightUpperarmBone);
            FindBone(m_characterDefinition.RightForearmBone, out m_rightForearmBone);

            FindBone(m_characterDefinition.WeaponBone, out m_weaponBone);
            FindBone(m_characterDefinition.LeftHandItemBone, out m_leftHandItemBone);
            FindBone(m_characterDefinition.RighHandItemBone, out m_rightHandItemBone);
            FindBone(m_characterDefinition.SpineBone, out m_spineBone);

            FindBone(m_characterDefinition.ModelRootBoneName, out m_rootBone);
            FindBone(m_characterDefinition.LeftHipBoneName, out m_leftHipBone);
            FindBone(m_characterDefinition.LeftKneeBoneName, out m_leftKneeBone);
            FindBone(m_characterDefinition.LeftAnkleBoneName, out m_leftAnkleBone);
            FindBone(m_characterDefinition.RightHipBoneName, out m_rightHipBone);
            FindBone(m_characterDefinition.RightKneeBoneName, out m_rightKneeBone);
            FindBone(m_characterDefinition.RightAnkleBoneName, out m_rightAnkleBone);           

            //footDimensions = new Vector3(m_characterDefinition.FootWidth, m_characterDefinition.AnkleHeight, m_characterDefinition.FootLenght);

            UpdateAnimation();
        }
        public void Initialize(AnimationPlayer player)
        {
            m_clip = player.Clip;
            m_model = player.Model;
            m_weight = player.Weight;
            m_timeScale = player.m_timeScale;
            m_justFirstFrame = player.m_justFirstFrame;

            m_boneCount = player.m_boneCount;
            if (m_boneInfos == null || m_boneInfos.Length < m_boneCount)
                m_boneInfos = new BoneInfo[m_boneCount];


            Position = player.Position;
            Looping = player.Looping;

            for (int b = 0; b < m_boneCount; b++)
            {
                if (m_boneInfos[b] == null)
                    m_boneInfos[b] = new BoneInfo();
                // Create it
                m_boneInfos[b].ClipBone = player.m_boneInfos[b].ClipBone;
                m_boneInfos[b].Player = this;
                    
                // Assign it to a model bone
                m_boneInfos[b].SetModel(m_model);
                m_boneInfos[b].CurrentKeyframe = player.m_boneInfos[b].CurrentKeyframe;
                m_boneInfos[b].SetKeyframes();
                m_boneInfos[b].SetPosition(Position);

                 if (MyFakes.ENABLE_BONES_AND_ANIMATIONS_DEBUG)
                 {
                     int index;
                     System.Diagnostics.Debug.Assert(m_model.FindBone(m_boneInfos[b].ClipBone.Name, out index) != null, "Can not find clip bone with name: "+m_boneInfos[b].ClipBone.Name+" in model: " + m_model.Name );
                 }
            }


            m_initialized = true;
        }