public void Stop(float blendTime) { if (this.m_state != AnimationBlendState.Stopped) { this.BlendPlayer.Done(); this.m_state = AnimationBlendState.BlendOut; this.m_currentBlendTime = 0f; this.m_totalBlendTime = blendTime; } }
public void Play(MyAnimationDefinition animationDefinition, bool firstPerson, MyFrameOption frameOption, float blendTime, float timeScale) { string model = firstPerson && !string.IsNullOrEmpty(animationDefinition.AnimationModelFPS) ? animationDefinition.AnimationModelFPS : animationDefinition.AnimationModel; System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(model)); if (string.IsNullOrEmpty(animationDefinition.AnimationModel)) { return; } if (animationDefinition.Status == MyAnimationDefinition.AnimationStatus.Unchecked) { var fsPath = System.IO.Path.IsPathRooted(model) ? model : System.IO.Path.Combine(MyFileSystem.ContentPath, model); if (!MyFileSystem.FileExists(fsPath)) { animationDefinition.Status = MyAnimationDefinition.AnimationStatus.Failed; return; } } animationDefinition.Status = MyAnimationDefinition.AnimationStatus.OK; MyModel animation = VRage.Game.Models.MyModels.GetModelOnlyAnimationData(model); Debug.Assert(animation != null && animation.Animations != null && animation.Animations.Clips.Count > 0); if (animation != null && animation.Animations == null || animation.Animations.Clips.Count == 0) { return; } Debug.Assert(animationDefinition.ClipIndex < animation.Animations.Clips.Count); if (animation.Animations.Clips.Count <= animationDefinition.ClipIndex) { return; } if (ActualPlayer.IsInitialized) { BlendPlayer.Initialize(ActualPlayer); } // Create a clip player and assign it to this model ActualPlayer.Initialize(animation, m_name, animationDefinition.ClipIndex, m_skinnedEntity, 1, timeScale, frameOption, m_bones, m_boneLODs); ActualPlayer.AnimationMwmPathDebug = model; ActualPlayer.AnimationNameDebug = animationDefinition.Id.SubtypeName; m_state = AnimationBlendState.BlendIn; m_currentBlendTime = 0; m_totalBlendTime = blendTime; }
public void UpdateAnimationState() { float blendRatio = 0; if (ActualPlayer.IsInitialized && m_currentBlendTime > 0) { blendRatio = 1; if (m_totalBlendTime > 0) { blendRatio = MathHelper.Clamp(m_currentBlendTime / m_totalBlendTime, 0, 1); } } if (ActualPlayer.IsInitialized) { if (m_state == AnimationBlendState.BlendOut) { ActualPlayer.Weight = 1 - blendRatio; if (blendRatio == 1) { ActualPlayer.Done(); m_state = AnimationBlendState.Stopped; } } if (m_state == AnimationBlendState.BlendIn) { if (m_totalBlendTime == 0) { blendRatio = 1; } ActualPlayer.Weight = blendRatio; if (BlendPlayer.IsInitialized) { BlendPlayer.Weight = 1; } if (blendRatio == 1) { m_state = AnimationBlendState.Playing; BlendPlayer.Done(); } } } }
public void UpdateAnimationState() { float num = 0f; if (this.ActualPlayer.IsInitialized && (this.m_currentBlendTime > 0f)) { num = 1f; if (this.m_totalBlendTime > 0f) { num = MathHelper.Clamp((float)(this.m_currentBlendTime / this.m_totalBlendTime), (float)0f, (float)1f); } } if (this.ActualPlayer.IsInitialized) { if (this.m_state == AnimationBlendState.BlendOut) { this.ActualPlayer.Weight = 1f - num; if (num == 1f) { this.ActualPlayer.Done(); this.m_state = AnimationBlendState.Stopped; } } if (this.m_state == AnimationBlendState.BlendIn) { if (this.m_totalBlendTime == 0f) { num = 1f; } this.ActualPlayer.Weight = num; if (this.BlendPlayer.IsInitialized) { this.BlendPlayer.Weight = 1f; } if (num == 1f) { this.m_state = AnimationBlendState.Playing; this.BlendPlayer.Done(); } } } }
public void Play(MyAnimationDefinition animationDefinition, bool firstPerson, MyFrameOption frameOption, float blendTime, float timeScale) { string animationModel; if (!firstPerson || string.IsNullOrEmpty(animationDefinition.AnimationModelFPS)) { animationModel = animationDefinition.AnimationModel; } else { animationModel = animationDefinition.AnimationModelFPS; } string path = animationModel; if (!string.IsNullOrEmpty(animationDefinition.AnimationModel)) { if ((animationDefinition.Status == MyAnimationDefinition.AnimationStatus.Unchecked) && !MyFileSystem.FileExists(Path.IsPathRooted(path) ? path : Path.Combine(MyFileSystem.ContentPath, path))) { animationDefinition.Status = MyAnimationDefinition.AnimationStatus.Failed; } else { animationDefinition.Status = MyAnimationDefinition.AnimationStatus.OK; MyModel modelOnlyAnimationData = MyModels.GetModelOnlyAnimationData(path, false); if ((((modelOnlyAnimationData == null) || (modelOnlyAnimationData.Animations != null)) && (modelOnlyAnimationData.Animations.Clips.Count != 0)) && (modelOnlyAnimationData.Animations.Clips.Count > animationDefinition.ClipIndex)) { if (this.ActualPlayer.IsInitialized) { this.BlendPlayer.Initialize(this.ActualPlayer); } this.ActualPlayer.Initialize(modelOnlyAnimationData, this.m_name, animationDefinition.ClipIndex, this.m_skinnedEntity, 1f, timeScale, frameOption, this.m_bones, this.m_boneLODs); this.ActualPlayer.AnimationMwmPathDebug = path; this.ActualPlayer.AnimationNameDebug = animationDefinition.Id.SubtypeName; this.m_state = AnimationBlendState.BlendIn; this.m_currentBlendTime = 0f; this.m_totalBlendTime = blendTime; } } } }
public void Play(MyAnimationDefinition animationDefinition, bool loop, float blendTime, float timeScale, bool justFirstFrame) { System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(animationDefinition.AnimationModel)); if (string.IsNullOrEmpty(animationDefinition.AnimationModel)) { return; } MyModel animation = MyModels.GetModelOnlyAnimationData(animationDefinition.AnimationModel); System.Diagnostics.Debug.Assert(animation.Animations.Clips.Count > 0); if (animation.Animations.Clips.Count == 0) { return; } System.Diagnostics.Debug.Assert(animationDefinition.ClipIndex < animation.Animations.Clips.Count); if (animation.Animations.Clips.Count <= animationDefinition.ClipIndex) { return; } AnimationClip clip = animation.Animations.Clips[animationDefinition.ClipIndex]; if (ActualPlayer.IsInitialized) { BlendPlayer.Initialize(ActualPlayer); } // Create a clip player and assign it to this model ActualPlayer.Initialize(clip, m_character, 1, timeScale, justFirstFrame, m_bones); ActualPlayer.Looping = loop; m_state = AnimationBlendState.BlendIn; m_currentBlendTime = 0; m_totalBlendTime = blendTime; }
public void Stop(float blendTime) { if (m_state != AnimationBlendState.Stopped) { BlendPlayer.Done(); m_state = AnimationBlendState.BlendOut; m_currentBlendTime = 0; m_totalBlendTime = blendTime; } }
public void Play(MyAnimationDefinition animationDefinition, bool firstPerson, MyFrameOption frameOption, float blendTime, float timeScale) { string model = firstPerson && !string.IsNullOrEmpty(animationDefinition.AnimationModelFPS) ? animationDefinition.AnimationModelFPS : animationDefinition.AnimationModel; System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(model)); if (string.IsNullOrEmpty(animationDefinition.AnimationModel)) return; if (animationDefinition.Status == MyAnimationDefinition.AnimationStatus.Unchecked) { var fsPath = System.IO.Path.IsPathRooted(model) ? model : System.IO.Path.Combine(MyFileSystem.ContentPath, model); if (!MyFileSystem.FileExists(fsPath)) { animationDefinition.Status = MyAnimationDefinition.AnimationStatus.Failed; return; } } animationDefinition.Status = MyAnimationDefinition.AnimationStatus.OK; MyModel animation = VRage.Game.Models.MyModels.GetModelOnlyAnimationData(model); Debug.Assert(animation != null && animation.Animations != null && animation.Animations.Clips.Count > 0); if (animation != null && animation.Animations == null || animation.Animations.Clips.Count == 0) return; Debug.Assert(animationDefinition.ClipIndex < animation.Animations.Clips.Count); if (animation.Animations.Clips.Count <= animationDefinition.ClipIndex) return; if (ActualPlayer.IsInitialized) { BlendPlayer.Initialize(ActualPlayer); } // Create a clip player and assign it to this model ActualPlayer.Initialize(animation, m_name, animationDefinition.ClipIndex, m_skinnedEntity, 1, timeScale, frameOption, m_bones, m_boneLODs); ActualPlayer.AnimationMwmPathDebug = model; ActualPlayer.AnimationNameDebug = animationDefinition.Id.SubtypeName; m_state = AnimationBlendState.BlendIn; m_currentBlendTime = 0; m_totalBlendTime = blendTime; }
public void UpdateAnimationState() { float blendRatio = 0; if (ActualPlayer.IsInitialized && m_currentBlendTime > 0) { blendRatio = 1; if (m_totalBlendTime > 0) blendRatio = MathHelper.Clamp(m_currentBlendTime / m_totalBlendTime, 0, 1); } if (ActualPlayer.IsInitialized) { if (m_state == AnimationBlendState.BlendOut) { ActualPlayer.Weight = 1 - blendRatio; if (blendRatio == 1) { ActualPlayer.Done(); m_state = AnimationBlendState.Stopped; } } if (m_state == AnimationBlendState.BlendIn) { if (m_totalBlendTime == 0) { blendRatio = 1; } ActualPlayer.Weight = blendRatio; if (BlendPlayer.IsInitialized) BlendPlayer.Weight = 1; if (blendRatio == 1) { m_state = AnimationBlendState.Playing; BlendPlayer.Done(); } } } }
public void Play(MyAnimationDefinition animationDefinition, bool loop, float blendTime, float timeScale, bool justFirstFrame) { System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(animationDefinition.AnimationModel)); if (string.IsNullOrEmpty(animationDefinition.AnimationModel)) return; MyModel animation = MyModels.GetModelOnlyAnimationData(animationDefinition.AnimationModel); System.Diagnostics.Debug.Assert(animation.Animations.Clips.Count > 0); if (animation.Animations.Clips.Count == 0) return; System.Diagnostics.Debug.Assert(animationDefinition.ClipIndex < animation.Animations.Clips.Count); if (animation.Animations.Clips.Count <= animationDefinition.ClipIndex) return; AnimationClip clip = animation.Animations.Clips[animationDefinition.ClipIndex]; if (ActualPlayer.IsInitialized) { BlendPlayer.Initialize(ActualPlayer); } // Create a clip player and assign it to this model ActualPlayer.Initialize(clip, m_character, 1, timeScale, justFirstFrame, m_bones); ActualPlayer.Looping = loop; m_state = AnimationBlendState.BlendIn; m_currentBlendTime = 0; m_totalBlendTime = blendTime; }
public void UpdateAnimation() { //Upper body blend float upperBlendRatio = 0; if (ActualPlayer.IsInitialized && m_currentBlendTime > 0) { upperBlendRatio = 1; if (m_totalBlendTime > 0) upperBlendRatio = MathHelper.Clamp(m_currentBlendTime / m_totalBlendTime, 0, 1); } if (ActualPlayer.IsInitialized) { if (m_state == AnimationBlendState.BlendOut) { ActualPlayer.Weight = 1 - upperBlendRatio; if (upperBlendRatio == 1) { ActualPlayer.Done(); m_state = AnimationBlendState.Stopped; } } if (m_state == AnimationBlendState.BlendIn) { ActualPlayer.Weight = upperBlendRatio; if (BlendPlayer.IsInitialized) BlendPlayer.Weight = 1; if (upperBlendRatio == 1) { m_state = AnimationBlendState.Playing; } } } }