bindings
looping
negative rates
This commit is contained in:
Glenn Maynard
2007-03-26 02:46:55 +00:00
parent 0a02a623a2
commit 9f259ed879
4 changed files with 19 additions and 12 deletions
+1 -2
View File
@@ -203,14 +203,13 @@ bool BeginnerHelper::Initialize( int iDancePadType )
m_pDancer[pl]->LoadMilkshapeAsciiBones( "Step-RIGHT", GetAnimPath(ANIM_RIGHT) );
m_pDancer[pl]->LoadMilkshapeAsciiBones( "Step-JUMPLR", GetAnimPath(ANIM_JUMPLR) );
m_pDancer[pl]->LoadMilkshapeAsciiBones(" rest", Character->GetRestAnimationPath() );
m_pDancer[pl]->SetDefaultAnimation( "rest" );
m_pDancer[pl]->SetDefaultAnimation( "rest" ); // Stay bouncing after a step has finished animating
m_pDancer[pl]->PlayAnimation( "rest" );
m_pDancer[pl]->SetRotationX( PLAYER_ANGLE );
m_pDancer[pl]->SetX( HELPER_X+PLAYER_X(pl) );
m_pDancer[pl]->SetY( HELPER_Y+10 );
m_pDancer[pl]->SetZoom( 20 );
m_pDancer[pl]->SetCullMode( CULL_NONE ); // many of the models floating around have the vertex order flipped
m_pDancer[pl]->m_bRevertToDefaultAnimation = true; // Stay bouncing after a step has finished animating
}
m_bInitialized = true;
+14 -6
View File
@@ -26,9 +26,9 @@ Model::Model()
SetCullMode( CULL_BACK );
m_pGeometry = NULL;
m_pCurAnimation = NULL;
m_bRevertToDefaultAnimation = false;
m_fDefaultAnimationRate = 1;
m_fCurAnimationRate = 1;
m_bLoop = true;
m_pTempGeometry = NULL;
}
@@ -108,8 +108,6 @@ void Model::LoadPieces( const RString &sMeshesPath, const RString &sMaterialsPat
void Model::LoadFromNode( const XNode* pNode )
{
Actor::LoadFromNode( pNode );
RString s1, s2, s3;
ActorUtil::GetAttrPath( pNode, "Meshes", s1 );
ActorUtil::GetAttrPath( pNode, "Materials", s2 );
@@ -119,6 +117,8 @@ void Model::LoadFromNode( const XNode* pNode )
ASSERT( !s1.empty() && !s2.empty() && !s3.empty() );
LoadPieces( s1, s2, s3 );
}
Actor::LoadFromNode( pNode );
}
@@ -576,16 +576,18 @@ void Model::AdvanceFrame( float fDeltaTime )
// LOG->Trace( "m_fCurFrame = %f", m_fCurFrame );
m_fCurFrame += FRAMES_PER_SECOND * fDeltaTime * m_fCurAnimationRate;
if( m_fCurFrame >= m_pCurAnimation->nTotalFrames )
if( m_fCurFrame < 0 || m_fCurFrame >= m_pCurAnimation->nTotalFrames )
{
if( m_bRevertToDefaultAnimation && m_sDefaultAnimation != "" )
if( m_sDefaultAnimation != "" )
{
this->PlayAnimation( m_sDefaultAnimation, m_fDefaultAnimationRate );
/* XXX: add to m_fCurFrame the wrapover from the previous
* m_fCurFrame-m_pCurAnimation->nTotalFrames, so it doesn't skip */
}
else if( m_bLoop )
wrap( m_fCurFrame, (float) m_pCurAnimation->nTotalFrames );
else
m_fCurFrame -= m_pCurAnimation->nTotalFrames;
m_fCurFrame = clamp( m_fCurFrame, 0, (float) m_pCurAnimation->nTotalFrames );
}
SetBones( m_pCurAnimation, m_fCurFrame, m_vpBones );
@@ -776,10 +778,16 @@ class LunaModel: public Luna<Model>
{
public:
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; }
static int rate( T* p, lua_State *L ) { p->SetRate(FArg(1)); return 0; }
LunaModel()
{
ADD_METHOD( playanimation );
ADD_METHOD( SetDefaultAnimation );
ADD_METHOD( loop );
ADD_METHOD( rate );
}
};
+3 -2
View File
@@ -30,6 +30,8 @@ public:
void LoadFromNode( const XNode* pNode );
void PlayAnimation( const RString &sAniName, float fPlayRate = 1 );
void SetRate( float fRate ) { m_fCurAnimationRate = fRate; }
void SetLoop( bool b ) { m_bLoop = b; }
virtual void Update( float fDelta );
virtual bool EarlyAbortDraw() const;
@@ -44,7 +46,6 @@ public:
RString GetDefaultAnimation() const { return m_sDefaultAnimation; };
void SetDefaultAnimation( RString sAnimation, float fPlayRate = 1 );
bool m_bRevertToDefaultAnimation;
bool MaterialsNeedNormals() const;
@@ -80,7 +81,7 @@ private:
RString m_sDefaultAnimation;
float m_fDefaultAnimationRate;
float m_fCurAnimationRate;
bool m_bLoop;
};
#endif
+1 -2
View File
@@ -109,8 +109,7 @@ void ScreenHowToPlay::Init()
ASSERT( !sRestFile.empty() );
m_pmCharacter->LoadMilkshapeAsciiBones( "rest",rndchar->GetRestAnimationPath() );
m_pmCharacter->SetDefaultAnimation( "rest" );
m_pmCharacter->PlayAnimation( "rest" );
m_pmCharacter->m_bRevertToDefaultAnimation = true; // Stay bouncing after a step has finished animating.
m_pmCharacter->PlayAnimation( "rest" ); // Stay bouncing after a step has finished animating.
m_pmCharacter->SetRotationX( 40 );
m_pmCharacter->SetCullMode( CULL_NONE ); // many of the models floating around have the vertex order flipped