From 6e7b44522ec268bdbc2eb4e770d4dc235cc0cd65 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 26 Mar 2007 22:54:21 +0000 Subject: [PATCH] SetPosition --- stepmania/src/Model.cpp | 8 ++++++++ stepmania/src/Model.h | 1 + 2 files changed, 9 insertions(+) diff --git a/stepmania/src/Model.cpp b/stepmania/src/Model.cpp index ba03a2e737..e132b849cd 100644 --- a/stepmania/src/Model.cpp +++ b/stepmania/src/Model.cpp @@ -564,6 +564,12 @@ void Model::PlayAnimation( const RString &sAniName, float fPlayRate ) UpdateTempGeometry(); } +void Model::SetPosition( float fSeconds ) +{ + m_fCurFrame = FRAMES_PER_SECOND * fSeconds; + m_fCurFrame = clamp( m_fCurFrame, 0, (float) m_pCurAnimation->nTotalFrames ); +} + void Model::AdvanceFrame( float fDeltaTime ) { if( m_pGeometry == NULL || @@ -777,6 +783,7 @@ bool Model::MaterialsNeedNormals() const class LunaModel: public Luna { public: + static int position( T* p, lua_State *L ) { p->SetPosition( FArg(1) ); return 0; } static int playanimation( T* p, lua_State *L ) { p->PlayAnimation(SArg(1),FArg(2)); return 0; } static int SetDefaultAnimation( T* p, lua_State *L ) { p->SetDefaultAnimation(SArg(1),FArg(2)); return 0; } static int loop( T* p, lua_State *L ) { p->SetLoop(BArg(1)); return 0; } @@ -784,6 +791,7 @@ public: LunaModel() { + ADD_METHOD( position ); ADD_METHOD( playanimation ); ADD_METHOD( SetDefaultAnimation ); ADD_METHOD( loop ); diff --git a/stepmania/src/Model.h b/stepmania/src/Model.h index 4c7deba592..37695ee4eb 100644 --- a/stepmania/src/Model.h +++ b/stepmania/src/Model.h @@ -32,6 +32,7 @@ public: void PlayAnimation( const RString &sAniName, float fPlayRate = 1 ); void SetRate( float fRate ) { m_fCurAnimationRate = fRate; } void SetLoop( bool b ) { m_bLoop = b; } + void SetPosition( float fSeconds ); virtual void Update( float fDelta ); virtual bool EarlyAbortDraw() const;