From 35251bb25b85d06fbc64f9c847f702593be0db68 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 1 Apr 2005 23:46:45 +0000 Subject: [PATCH] load Models from XML (alternative to a .model file) --- stepmania/src/Model.cpp | 18 ++++++++++++++++++ stepmania/src/Model.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/stepmania/src/Model.cpp b/stepmania/src/Model.cpp index 3acdf87345..4d8bd7c314 100644 --- a/stepmania/src/Model.cpp +++ b/stepmania/src/Model.cpp @@ -18,6 +18,8 @@ LUA_REGISTER_CLASS( Model ) // lua end +REGISTER_ACTOR_CLASS( Model ) + const float FRAMES_PER_SECOND = 30; const CString DEFAULT_ANIMATION_NAME = "default"; @@ -139,6 +141,22 @@ void Model::LoadPieces( CString sMeshesPath, CString sMaterialsPath, CString sBo } } +void Model::LoadFromNode( const CString& sDir, const XNode* pNode ) +{ + Actor::LoadFromNode( sDir, pNode ); + + CString s1, s2, s3; + pNode->GetAttrValue( "Meshes", s1 ); + pNode->GetAttrValue( "Materials", s2 ); + pNode->GetAttrValue( "Bones", s3 ); + if( !s1.empty() || !s2.empty() || !s3.empty() ) + { + ASSERT( !s1.empty() && !s2.empty() && !s3.empty() ); + LoadPieces( sDir+s1, sDir+s2, sDir+s3 ); + } +} + + void Model::LoadMaterialsFromMilkshapeAscii( CString sPath ) { FixSlashesInPlace(sPath); diff --git a/stepmania/src/Model.h b/stepmania/src/Model.h index 86f024ac18..b008e195e9 100644 --- a/stepmania/src/Model.h +++ b/stepmania/src/Model.h @@ -39,6 +39,9 @@ public: void LoadMilkshapeAscii( CString sFile ); void LoadMaterialsFromMilkshapeAscii( CString sPath ); bool LoadMilkshapeAsciiBones( CString sAniName, CString sPath ); + + void LoadFromNode( const CString& sDir, const XNode* pNode ); + void PlayAnimation( CString sAniName, float fPlayRate = 1 ); virtual void Update( float fDelta );