From 82a8340afd1fe1d23bcdb6f11b8177c569012495 Mon Sep 17 00:00:00 2001 From: Kevin Slaughter Date: Wed, 20 Aug 2003 09:15:53 +0000 Subject: [PATCH] Added ability to skip to frame xx in the current animation. Used in HowToPlay. Also allows an animation freeze, if re-iterated --- stepmania/src/Model.cpp | 19 +++++++++++++++++-- stepmania/src/Model.h | 4 ++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/stepmania/src/Model.cpp b/stepmania/src/Model.cpp index 7c9ee4da26..3d0b2a762e 100644 --- a/stepmania/src/Model.cpp +++ b/stepmania/src/Model.cpp @@ -17,6 +17,7 @@ #include "RageTextureManager.h" #include "IniFile.h" #include "RageFile.h" +#include "RageLog.h" const float FRAMES_PER_SECOND = 30; const CString DEFAULT_ANIMATION_NAME = "default"; @@ -27,6 +28,7 @@ Model::Model () m_bTextureWrapping = true; m_bUseZBuffer = true; m_pCurAnimation = NULL; + m_bRevertToDefaultAnimation = false; } Model::~Model () @@ -676,6 +678,10 @@ void Model::DrawPrimitives() } +void Model::SetDefaultAnimation( CString sAnimation ) +{ + m_sDefaultAnimation = sAnimation; +} void Model::PlayAnimation( CString sAniName ) { @@ -752,8 +758,16 @@ Model::AdvanceFrame (float dt) return; // bail early m_fCurrFrame += FRAMES_PER_SECOND * dt; - if (m_fCurrFrame > (float) m_pCurAnimation->nTotalFrames) - m_fCurrFrame = 0.0f; + if (m_fCurrFrame >= (float) m_pCurAnimation->nTotalFrames) + { + if( (m_bRevertToDefaultAnimation) && (m_sDefaultAnimation != "") ) + { + this->PlayAnimation( m_sDefaultAnimation ); + m_fCurrFrame = 0.0f; + return; + } + } + int nBoneCount = (int)m_pCurAnimation->Bones.size(); int i, j; @@ -870,6 +884,7 @@ void Model::Update( float fDelta ) { Actor::Update( fDelta ); AdvanceFrame( fDelta ); + for( int i=0; i<(int)m_Materials.size(); i++ ) m_Materials[i].aniTexture.Update( fDelta ); } diff --git a/stepmania/src/Model.h b/stepmania/src/Model.h index 7daef5af8a..e33a0e7b6e 100644 --- a/stepmania/src/Model.h +++ b/stepmania/src/Model.h @@ -60,6 +60,9 @@ public: float GetCurFrame(); void SetFrame( float fNewFrame ); virtual int GetNumStates(); + CString GetDefaultAnimation() { return m_sDefaultAnimation; }; + void SetDefaultAnimation( CString sAnimation ); + bool m_bRevertToDefaultAnimation; private: @@ -73,6 +76,7 @@ private: typedef vector RageModelVertexVector; vector m_vTempVerticesByBone; float m_fCurrFrame; + CString m_sDefaultAnimation; };