Ejemplo n.º 1
0
 static int GetAnimationPlayerHash(AnimationPlayer player)
 {
     float positionPrecision = 10;
     return (player.Name.GetHashCode() * 397) ^
         (MyUtils.GetHash(player.m_skinnedEntity.Model.UniqueId) * 397) ^
             (((int)(player.m_position.GetHashCode() * positionPrecision)) * 397) ^ 
              player.m_currentLODIndex.GetHashCode();
 }
Ejemplo n.º 2
0
            public BoneInfo(AnimationClip.Bone bone, AnimationPlayer player)
            {
                this.ClipBone = bone;
                Player = player;

                SetKeyframes();
                SetPosition(0);

                m_isConst = bone.Keyframes.Count == 1;
            }
Ejemplo n.º 3
0
        public void Initialize(AnimationPlayer player)
        {
            m_clip = player.Clip;
            m_skinnedEntity = player.m_skinnedEntity;
            m_weight = player.Weight;
            m_timeScale = player.m_timeScale;
            m_frameOption = player.m_frameOption;

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


            Position = player.Position;

            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_skinnedEntity);
                m_boneInfos[b].CurrentKeyframe = player.m_boneInfos[b].CurrentKeyframe;
                m_boneInfos[b].SetPosition(Position);

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


            m_initialized = true;
        }
Ejemplo n.º 4
0
 public void Clear()
 {
     m_currentKeyframe = 0;
     m_isConst = false;
     m_assignedBone = null;
     Rotation = default(Quaternion);
     Translation = Vector3.Zero;
     Player = null;
     Keyframe1 = null;
     Keyframe2 = null;
     m_clipBone = null;
 }
Ejemplo n.º 5
0
 public BoneInfo(MyAnimationClip.Bone bone, AnimationPlayer player)
 {
     Init(bone, player);
 }
Ejemplo n.º 6
0
        public void Initialize(AnimationPlayer player)
        {
            if (m_hash != 0)
            {
                CachedAnimationPlayers.Remove(m_hash);
                m_hash = 0;
            }

            Name = player.Name;
            m_duration = player.m_duration;
            m_skinnedEntity = player.m_skinnedEntity;
            m_weight = player.Weight;
            m_timeScale = player.m_timeScale;
            m_frameOption = player.m_frameOption;

            foreach(var list in m_boneLODs.Values)
                list.Clear();
            //m_boneLODs.Clear();

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


            Position = player.Position;


            for (int b = 0; b < m_boneCount; b++)
            {
                var boneInfo = m_boneInfos[b];
                if (boneInfo == null)
                {
                    boneInfo = new BoneInfo();
                    m_boneInfos[b] = boneInfo;
                }

                // Create it
                boneInfo.ClipBone = player.m_boneInfos[b].ClipBone;
                boneInfo.Player = this;
                    
                // Assign it to a model bone
                boneInfo.SetModel(m_skinnedEntity);
                boneInfo.CurrentKeyframe = player.m_boneInfos[b].CurrentKeyframe;
                boneInfo.SetPosition(Position);


                if (player.m_boneLODs != null && boneInfo.ModelBone != null && ENABLE_ANIMATION_LODS)
                {
                    foreach (var boneLOD in player.m_boneLODs)
                    {
                        List<BoneInfo> lodBones;
                        if (!m_boneLODs.TryGetValue(boneLOD.Key, out lodBones))
                        {
                            lodBones = new List<BoneInfo>();
                            m_boneLODs.Add(boneLOD.Key, lodBones);
                        }

                        foreach (var boneName in boneLOD.Value)
                        {
                            if (boneName.ModelBone == null)
                                continue;

                            if (boneInfo.ModelBone.Name == boneName.ModelBone.Name)
                            {
                                lodBones.Add(boneInfo);
                                break;
                            }
                        }
                    }
                }

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


            m_initialized = true;
        }