Added exportModelsToTrenchBroom console command

This commit is contained in:
Robert Beckebans 2022-01-07 18:46:35 +01:00
parent a89dc048e8
commit 3cc6c0744e
4 changed files with 122 additions and 1 deletions

View file

@ -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 `<map>`
[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)

View file

@ -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<const idDeclModelDef*>( 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
/*

View file

@ -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++ )

View file

@ -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
===============
*/