From 3cc6c0744e2a2e6b5ce25288248fd0e493381b9d Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Fri, 7 Jan 2022 18:46:35 +0100 Subject: [PATCH] Added exportModelsToTrenchBroom console command --- RELEASE-NOTES.md | 24 ++++++++++ neo/framework/DeclManager.cpp | 90 +++++++++++++++++++++++++++++++++++ neo/framework/FileSystem.cpp | 4 ++ neo/idlib/MapFile.cpp | 5 +- 4 files changed, 122 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 894384c5..fb8c59ef 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -13,6 +13,30 @@ RBDOOM-3-BFG Release Notes - https://github.com/RobertBeckebans/RBDOOM-3-BFG Thank you for downloading RBDOOM-3-BFG. +_______________________________________ + +TBD - RBDOOM-3-BFG 1.3.1 +_______________________________ + + +## General Changelog + +[TRENCHBROOM] + +* Tweaked exportFGD command for new icons + +* Added console command convertMapToValve220 `` + +[MISCELLANEOUS] + +* Added CMake options STANDALONE and DOOM_CLASSIC + +* Added CMake options STANDALONE and DOOM_CLASSIC + +[ASSETS] + +* + _______________________________________ 30 October 2021 - RBDOOM-3-BFG 1.3.0 - Download it from the [RBDOOM-3-BFG ModDB Page](https://www.moddb.com/mods/rbdoom-3-bfg) diff --git a/neo/framework/DeclManager.cpp b/neo/framework/DeclManager.cpp index 0b67f0cc..d3ecb68d 100644 --- a/neo/framework/DeclManager.cpp +++ b/neo/framework/DeclManager.cpp @@ -263,6 +263,7 @@ private: // RB begin static void ExportDeclsToBlender_f( const idCmdArgs& args ); static void ExportDeclsToTrenchBroom_f( const idCmdArgs& args ); + static void ExportModelsToTrenchBroom_f( const idCmdArgs& args ); // RB end }; @@ -960,6 +961,7 @@ void idDeclManagerLocal::Init() // RB begin cmdSystem->AddCommand( "exportEntityDefsToBlender", ExportDeclsToBlender_f, CMD_FL_SYSTEM, "exports all entity and model defs to exported/entities.json" ); cmdSystem->AddCommand( "exportFGD", ExportDeclsToTrenchBroom_f, CMD_FL_SYSTEM, "exports all entity and model defs to exported/_tb/Doom3.fgd" ); + cmdSystem->AddCommand( "exportModelsToTrenchBroom", ExportModelsToTrenchBroom_f, CMD_FL_SYSTEM, "exports all generated models like blwo, base .. to _tb/*.obj" ); // RB end common->Printf( "------------------------------\n" ); @@ -2164,6 +2166,7 @@ void idDeclManagerLocal::ExportDeclsToTrenchBroom_f( const idCmdArgs& args ) solidClassNames.AddUnique( "func_plat" ); solidClassNames.AddUnique( "func_rotating" ); solidClassNames.AddUnique( "func_splinemover" ); + solidClassNames.AddUnique( "func_static" ); solidClassNames.AddUnique( "moveable_base" ); solidClassNames.AddUnique( "trigger_" ); @@ -2729,6 +2732,93 @@ void idDeclManagerLocal::ExportDeclsToTrenchBroom_f( const idCmdArgs& args ) //declManagerLocal.Reload( true ); common->FatalError( "Exporting successful, need to restart manually" ); } + + +void idDeclManagerLocal::ExportModelsToTrenchBroom_f( const idCmdArgs& args ) +{ + extern idCVar postLoadExportModels; + postLoadExportModels.SetBool( true ); + + // avoid media cache + com_editors |= EDITOR_EXPORTDEFS; + + int totalModelsCount = 0; + + { + idFileList* files; + + files = fileSystem->ListFilesTree( "generated", ".blwo|.base|.bmd5mesh", true ); + for( int f = 0; f < files->GetList().Num(); f++ ) + { + idStr modelName = files->GetList()[ f ]; + modelName.StripLeadingOnce( "generated/rendermodels/" ); + + idStr ext; + modelName.ExtractFileExtension( ext ); + + if( ext.Icmp( "blwo" ) == 0 ) + { + modelName.SetFileExtension( "lwo" ); + } + + if( ext.Icmp( "base" ) == 0 ) + { + modelName.SetFileExtension( "ase" ); + } + + if( ext.Icmp( "bdae" ) == 0 ) + { + modelName.SetFileExtension( "dae" ); + } + + if( ext.Icmp( "bmd5mesh" ) == 0 ) + { + modelName.SetFileExtension( "md5mesh" ); + } + + idLib::Printf( "Exporting model '%s'\n", modelName.c_str() ); + + // export models as OBJ + //idStrStatic< MAX_OSPATH > exportedModelFileName; + + // 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( modelName ); + + //exportedModelFileName = "_tb/"; + //exportedModelFileName.AppendPath( modelName ); + //exportedModelFileName.SetFileExtension( ".obj" ); + } + /* + else + { + idRenderModel* renderModel = modelDef->ModelHandle(); + if( renderModel ) + { + exportedModelFileName = "_tb/"; + exportedModelFileName.AppendPath( renderModel->Name() ); + exportedModelFileName.SetFileExtension( ".obj" ); + } + } + */ + + totalModelsCount++; + } + + fileSystem->FreeFileList( files ); + } + com_editors &= ~EDITOR_EXPORTDEFS; + postLoadExportModels.SetBool( false ); + + common->Printf( "----------------------------\n" ); + common->Printf( "Wrote %d Models.\n", totalModelsCount ); + + common->FatalError( "Exporting successful, need to restart manually" ); +} // RB end /* diff --git a/neo/framework/FileSystem.cpp b/neo/framework/FileSystem.cpp index 743a8fd5..d5d78cb8 100644 --- a/neo/framework/FileSystem.cpp +++ b/neo/framework/FileSystem.cpp @@ -2278,6 +2278,9 @@ int idFileSystemLocal::GetFileList( const char* relativePath, const idStrList& e // make sure the file is not in a subdirectory int j = pathLength; + + // RB: subdirectories are good!!! +#if 0 for( ; rt.filename[j + 1] != '\0'; j++ ) { if( rt.filename[ j ] == '/' ) @@ -2289,6 +2292,7 @@ int idFileSystemLocal::GetFileList( const char* relativePath, const idStrList& e { continue; } +#endif // check for extension match for( j = 0; j < extensions.Num(); j++ ) diff --git a/neo/idlib/MapFile.cpp b/neo/idlib/MapFile.cpp index f88a27d7..392d67af 100644 --- a/neo/idlib/MapFile.cpp +++ b/neo/idlib/MapFile.cpp @@ -3,7 +3,8 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -Copyright (C) 2015-2021 Robert Beckebans +Copyright (C) 2015-2022 Robert Beckebans +Copyright (C) 2020 Admer (id Tech Fox) This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). @@ -1421,6 +1422,8 @@ unsigned int idMapEntity::GetGeometryCRC() const /* =============== +Admer + idMapEntity::CalculateBrushOrigin =============== */