public void Update(float dt) { if (Anim != null) { if (playingState == AnimPlayingState.Stopped) { return; } if (playingState == AnimPlayingState.Playing) { AnimPos += dt; if (AnimPos > durationInSeconds) { if (Loop) { while (AnimPos > durationInSeconds) { AnimPos -= durationInSeconds; } } else { playingState = AnimPlayingState.Stopped; dt = AnimPos - durationInSeconds - ENDPOINT_EPSILON; AnimPos = durationInSeconds; } } } else if (playingState == AnimPlayingState.PlayingInReverse) { dt = -dt; AnimPos += dt; if (AnimPos < 0.0f) { if (Loop) { while (AnimPos < 0.0f) { AnimPos += durationInSeconds; } } else { playingState = AnimPlayingState.Stopped; dt = dt - AnimPos + ENDPOINT_EPSILON; AnimPos = 0.0f; } } } for (int i = 0; i < Anim.JointAnims.Count; ++i) { JointAnimStates[i].Update(dt, ref parentClipInstance.JointStates[JointAnimStates[i].JointAnim.JointId]); } } }
public void Play(ClipAnim anim, bool loop, bool forwards) { Anim = anim; AnimPos = 0.0f; Loop = loop; durationInSeconds = (float)Anim.Duration / Anim.Framerate; playingState = forwards ? AnimPlayingState.Playing : AnimPlayingState.PlayingInReverse; for (int i = 0; i < Anim.JointAnims.Count; ++i) { JointAnimStates[i] = Anim.JointAnims[i].CreateState(); } }
public void Play(ClipAnim anim, bool loop, bool forwards, float speedMod = 1f) { System.Diagnostics.Debug.Assert(anim != null); System.Diagnostics.Debug.Assert(speedMod > 0.0f); Anim = anim; AnimPos = 0.0f; Loop = loop; speedModifier = speedMod; durationInSeconds = (1f / speedModifier) * ((float)Anim.Duration / Anim.Framerate); playingState = forwards ? AnimPlayingState.Playing : AnimPlayingState.PlayingInReverse; for (int i = 0; i < Anim.JointAnims.Count; ++i) { JointAnimStates[i] = Anim.JointAnims[i].CreateState(); } }
public void Stop() { playingState = AnimPlayingState.Stopped; }
public void Update(float dt) { if (Anim != null) { if (playingState == AnimPlayingState.Stopped) return; if (playingState == AnimPlayingState.Playing) { AnimPos += dt; if (AnimPos > durationInSeconds) { if (Loop) { while (AnimPos > durationInSeconds) AnimPos -= durationInSeconds; } else { playingState = AnimPlayingState.Stopped; dt = AnimPos - durationInSeconds - ENDPOINT_EPSILON; AnimPos = durationInSeconds; } } } else if (playingState == AnimPlayingState.PlayingInReverse) { dt = -dt; AnimPos += dt; if (AnimPos < 0.0f) { if (Loop) { while (AnimPos < 0.0f) AnimPos += durationInSeconds; } else { playingState = AnimPlayingState.Stopped; dt = dt - AnimPos + ENDPOINT_EPSILON; AnimPos = 0.0f; } } } for (int i = 0; i < Anim.JointAnims.Count; ++i) { JointAnimStates[i].Update(dt, ref parentClipInstance.JointStates[JointAnimStates[i].JointAnim.JointId]); } } }
public void Play(ClipAnim anim, bool loop, bool forwards, float speedMod=1f) { System.Diagnostics.Debug.Assert(anim != null); System.Diagnostics.Debug.Assert(speedMod > 0.0f); Anim = anim; AnimPos = 0.0f; Loop = loop; speedModifier = speedMod; durationInSeconds = (1f / speedModifier) * ((float)Anim.Duration / Anim.Framerate); playingState = forwards ? AnimPlayingState.Playing : AnimPlayingState.PlayingInReverse; for (int i = 0; i < Anim.JointAnims.Count; ++i) { JointAnimStates[i] = Anim.JointAnims[i].CreateState(); } }