diff --git a/neo/framework/DeclManager.cpp b/neo/framework/DeclManager.cpp index 1e556a27..927125d0 100644 --- a/neo/framework/DeclManager.cpp +++ b/neo/framework/DeclManager.cpp @@ -2063,6 +2063,8 @@ typedef struct evar_s idStr desc; } evar_t; +#include // idDeclModelDef + void idDeclManagerLocal::ExportDeclsToTrenchBroom_f( const idCmdArgs& args ) { extern idCVar postLoadExportModels; @@ -2148,7 +2150,7 @@ void idDeclManagerLocal::ExportDeclsToTrenchBroom_f( const idCmdArgs& args ) idLib::Printf( "Failed to entity declarations data to FGD.\n" ); } - file->Printf( "// DOOM 3 BFG game definition file (.fgd) created by RBDOOM-3-BFG\n\n" ); + file->Printf( "// DOOM 3 BFG game definition file (.fgd) generated by %s\n\n", ENGINE_VERSION ); for( int d = 0; d < count; d++ ) { @@ -2265,8 +2267,9 @@ void idDeclManagerLocal::ExportDeclsToTrenchBroom_f( const idCmdArgs& args ) file->Printf( "color(%i %i %i) ", int32( color.x * 255 ) & 0xFF, int32( color.y * 255 ) & 0xFF, int32( color.z * 255 ) & 0xFF ); } -#if 0 - if( idStr::Icmp( decl->GetName(), "monster_zombie_maint_bald" ) == 0 ) +#if 1 + //if( idStr::Icmp( decl->GetName(), "monster_zombie_maint_bald" ) == 0 ) + if( idStr::Icmp( decl->GetName(), "monster_demon_imp" ) == 0 ) { text += " "; } @@ -2409,36 +2412,51 @@ void idDeclManagerLocal::ExportDeclsToTrenchBroom_f( const idCmdArgs& args ) bool writeModel = false; idStrStatic< MAX_OSPATH > exportedModelFileName; - kv = dictToWrite.MatchPrefix( "model" ); - while( kv ) + if( idStr::Icmp( decl->GetName(), "light" ) != 0 ) { - if( kv->GetValue().Length() ) - { - declManager->MediaPrint( "Precaching model %s\n", kv->GetValue().c_str() ); + //kv = dictToWrite.MatchPrefix( "model" ); + //while( kv ) - // precache model/animations - const idDecl* modelDef = declManager->FindType( DECL_MODELDEF, kv->GetValue(), false ); - if( modelDef == NULL ) + const idKeyValue* kv = dictToWrite.FindKey( "model" ); + if( kv ) + { + if( kv->GetValue().Length() ) { - // there is no modelDef so use direct path - renderModelManager->FindModel( kv->GetValue() ); + declManager->MediaPrint( "Precaching model %s\n", kv->GetValue().c_str() ); + + // HACK + writeModel = true; + + // precache model/animations + const idDeclModelDef* modelDef = static_cast( declManager->FindType( DECL_MODELDEF, kv->GetValue(), false ) ); + if( modelDef == NULL ) + { + // there is no modelDef so use direct path + renderModelManager->FindModel( kv->GetValue() ); + + exportedModelFileName = "_tb/"; + exportedModelFileName.AppendPath( kv->GetValue() ); + exportedModelFileName.SetFileExtension( ".obj" ); + } + else + { + //exportedModelFileName = postLoadExportModelName.GetString(); + + idRenderModel* renderModel = modelDef->ModelHandle(); + if( renderModel ) + { + exportedModelFileName = "_tb/"; + exportedModelFileName.AppendPath( renderModel->Name() ); + exportedModelFileName.SetFileExtension( ".obj" ); + } + } } - // HACK - writeModel = true; - - exportedModelFileName = postLoadExportModelName.GetString(); - //exportedFileName = "_tb/"; - //exportedFileName.AppendPath( modelDef->GetModelName() ); - //exportedFileName.SetFileExtension( ".obj" ); - - //dictToWrite.Set( kv->GetKey(), exportedFileName ); + //kv = dictToWrite.MatchPrefix( "model", kv ); } - - kv = dictToWrite.MatchPrefix( "model", kv ); } - if( writeModel ) + if( writeModel && !exportedModelFileName.IsEmpty() ) { file->Printf( "model({ \"path\": \"%s\" }) ", exportedModelFileName.c_str() ); } diff --git a/neo/renderer/Model.cpp b/neo/renderer/Model.cpp index 390be398..0653af17 100644 --- a/neo/renderer/Model.cpp +++ b/neo/renderer/Model.cpp @@ -738,7 +738,7 @@ void idRenderModelStatic::WriteBinaryModel( idFile* file, ID_TIME_T* _timeStamp } // RB begin -void idRenderModelStatic::ExportOBJ( idFile* objFile, idFile* mtlFile, ID_TIME_T* _timeStamp ) const +void idRenderModelStatic::ExportOBJ( idFile* objFile, idFile* mtlFile, ID_TIME_T* _timeStamp ) { if( objFile == NULL || mtlFile == NULL ) { @@ -746,7 +746,7 @@ void idRenderModelStatic::ExportOBJ( idFile* objFile, idFile* mtlFile, ID_TIME_T return; } - //objFile->Printf( "// generated by %s\n//\n\n", ENGINE_VERSION ); + objFile->Printf( "# generated by %s\n\n", ENGINE_VERSION ); int numVerts = 0; idList< const idMaterial* > materials; diff --git a/neo/renderer/Model.h b/neo/renderer/Model.h index 794855e0..a32d49b2 100644 --- a/neo/renderer/Model.h +++ b/neo/renderer/Model.h @@ -173,7 +173,7 @@ public: virtual bool SupportsBinaryModel() = 0; // RB begin - virtual void ExportOBJ( idFile* objFile, idFile* mtlFile, ID_TIME_T* _timeStamp = NULL ) const = 0; + virtual void ExportOBJ( idFile* objFile, idFile* mtlFile, ID_TIME_T* _timeStamp = NULL ) = 0; // RB end // renderBump uses this to load the very high poly count models, skipping the diff --git a/neo/renderer/Model_local.h b/neo/renderer/Model_local.h index f059fa87..ec902cd2 100644 --- a/neo/renderer/Model_local.h +++ b/neo/renderer/Model_local.h @@ -59,7 +59,7 @@ public: } // RB begin - virtual void ExportOBJ( idFile* objFile, idFile* mtlFile, ID_TIME_T* _timeStamp = NULL ) const; + virtual void ExportOBJ( idFile* objFile, idFile* mtlFile, ID_TIME_T* _timeStamp = NULL ); // RB end virtual void PartialInitFromFile( const char* fileName ); @@ -233,6 +233,10 @@ public: return true; } + // RB begin + virtual void ExportOBJ( idFile* objFile, idFile* mtlFile, ID_TIME_T* _timeStamp = NULL ); + // RB end + private: idList joints; idList defaultPose; diff --git a/neo/renderer/Model_md5.cpp b/neo/renderer/Model_md5.cpp index 57279bd8..d34b3a84 100644 --- a/neo/renderer/Model_md5.cpp +++ b/neo/renderer/Model_md5.cpp @@ -1607,3 +1607,38 @@ int idRenderModelMD5::Memory() const } return total; } + + +// RB begin +void idRenderModelMD5::ExportOBJ( idFile* objFile, idFile* mtlFile, ID_TIME_T* _timeStamp ) +{ + if( objFile == NULL || mtlFile == NULL ) + { + common->Printf( "Failed to ExportOBJ\n" ); + return; + } + + renderEntity_t ent; + + memset( &ent, 0, sizeof( ent ) ); + + ent.bounds.Clear(); + ent.suppressSurfaceInViewID = 0; + + ent.numJoints = NumJoints(); + if( ent.numJoints > 0 ) + { + ent.joints = ( idJointMat* )Mem_Alloc16( SIMD_ROUND_JOINTS( ent.numJoints ) * sizeof( *ent.joints ), TAG_JOINTMAT ); + + SIMD_INIT_LAST_JOINT( ent.joints, ent.numJoints ); + + idRenderModel* newmodel = InstantiateDynamicModel( &ent, NULL, NULL ); + newmodel->ExportOBJ( objFile, mtlFile, _timeStamp ); + + Mem_Free16( ent.joints ); + ent.joints = NULL; + + delete newmodel; + } +} +// RB end \ No newline at end of file