mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 06:34:10 +00:00
exportModelsToTrenchBroom writes another FGD with helper entities
This commit is contained in:
parent
4364dea54b
commit
b2f68faffe
1 changed files with 109 additions and 2 deletions
|
@ -2784,17 +2784,45 @@ void idDeclManagerLocal::ExportModelsToTrenchBroom_f( const idCmdArgs& args )
|
|||
com_editors |= EDITOR_EXPORTDEFS;
|
||||
|
||||
int totalModelsCount = 0;
|
||||
int totalEntitiesCount = 0;
|
||||
|
||||
idFileList* files = fileSystem->ListFilesTree( "generated", ".blwo|.base|.bmd5mesh", true, true );
|
||||
|
||||
idStr fgdFileName;
|
||||
fgdFileName.Format( "exported/_tb/DOOM-3-models.fgd" );
|
||||
idFileLocal fgdFile( fileSystem->OpenFileWrite( fgdFileName, "fs_basepath" ) );
|
||||
if( fgdFile == NULL )
|
||||
{
|
||||
common->Printf( "Failed to write entity declarations data to FGD.\n" );
|
||||
}
|
||||
|
||||
fgdFile->Printf( "// DOOM 3 BFG models definition file (.fgd) generated by %s\n\n", ENGINE_VERSION );
|
||||
|
||||
|
||||
fgdFile->Printf( "@BaseClass color(0 127 204) = auto_generated_model : \"Just a model\"\n[\n" );
|
||||
//fgdFile->Printf( "name(string) : \"\" : \"\"\n" );
|
||||
fgdFile->Printf( "\t spawnclass(string) : \"\" : \"idStaticEntity\"\n" );
|
||||
fgdFile->Printf( "\t solid(boolean) : \"whether the object should be solid or not.\" : 1\n" );
|
||||
fgdFile->Printf( "\t noclipmodel(boolean) : \"0 by default. Sets whether or not to generate a collision model for an ASE/LWO func_static at level load. (Set to 1 for stuff the player can't interact with. This will save memory.)\" : 0\n" );
|
||||
fgdFile->Printf( "\t hide(boolean) : \"whether the object should be visible when spawned. you need to set a value for triggering on/off to work\"\n" );
|
||||
fgdFile->Printf( "\t gui_noninteractive(boolean) : \"any gui attached will not be interactive\"\n" );
|
||||
fgdFile->Printf( "\t inline(boolean) : \"If true, turn the model into map geometry at dmap time\"\n" );
|
||||
fgdFile->Printf( "\t angles(string) : \"\" : \"0 0 0\"\n" );
|
||||
fgdFile->Printf( "\t gui(string) : \"gui attached to this static, gui2 and gui3 also work\"\n" );
|
||||
fgdFile->Printf( "\t gui_demonic(string) : \"demonic gui attached to this statit, gui_demonic2 and gui_demonic3 also work\"\n]\n\n" );
|
||||
|
||||
for( int f = 0; f < files->GetList().Num(); f++ )
|
||||
{
|
||||
totalModelsCount++;
|
||||
|
||||
idStr modelName = files->GetList()[ f ];
|
||||
modelName.StripLeadingOnce( "generated/rendermodels/" );
|
||||
|
||||
idStr ext;
|
||||
modelName.ExtractFileExtension( ext );
|
||||
|
||||
bool dynamicModel = false;
|
||||
|
||||
if( ext.Icmp( "blwo" ) == 0 )
|
||||
{
|
||||
modelName.SetFileExtension( "lwo" );
|
||||
|
@ -2813,20 +2841,99 @@ void idDeclManagerLocal::ExportModelsToTrenchBroom_f( const idCmdArgs& args )
|
|||
if( ext.Icmp( "bmd5mesh" ) == 0 )
|
||||
{
|
||||
modelName.SetFileExtension( "md5mesh" );
|
||||
dynamicModel = true;
|
||||
}
|
||||
|
||||
idLib::Printf( "Exporting model '%s'\n", modelName.c_str() );
|
||||
|
||||
renderModelManager->FindModel( modelName );
|
||||
// make an OBJ version of the model for TrenchBroom
|
||||
idRenderModel* renderModel = renderModelManager->FindModel( modelName );
|
||||
|
||||
#if 1
|
||||
if( idStr::Icmpn( modelName, "models/mapobjects", 17 ) != 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( idStr::Icmpn( modelName, "models/items", 12 ) == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( idStr::Icmpn( modelName, "models/particles", 16 ) == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( idStr::Icmpn( modelName, "models/weapons", 14 ) == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
idBounds bounds = renderModel->Bounds();
|
||||
|
||||
// put model as mapobject into the models FGD
|
||||
if( !renderModel->IsDefaultModel() && bounds.GetVolume() > 0 && bounds.GetRadius() < 1400 )
|
||||
{
|
||||
idStrStatic< MAX_OSPATH > exportedModelFileName;
|
||||
exportedModelFileName = "_tb/";
|
||||
exportedModelFileName.AppendPath( modelName );
|
||||
exportedModelFileName.SetFileExtension( ".obj" );
|
||||
|
||||
|
||||
idStrStatic< MAX_OSPATH > entityName;
|
||||
|
||||
if( idStr::Icmpn( modelName, "models/mapobjects", 17 ) == 0 )
|
||||
{
|
||||
modelName.StripLeadingOnce( "models/mapobjects" );
|
||||
|
||||
entityName = "mob";
|
||||
entityName.AppendPath( modelName );
|
||||
}
|
||||
else
|
||||
{
|
||||
modelName.StripLeadingOnce( "models/" );
|
||||
|
||||
entityName = "mdl";
|
||||
entityName.AppendPath( modelName );
|
||||
}
|
||||
|
||||
entityName.BackSlashesToSlashes();
|
||||
entityName.ReplaceChar( '/', '_' );
|
||||
entityName.ReplaceChar( '(', '_' );
|
||||
entityName.ReplaceChar( ')', '_' );
|
||||
entityName.StripFileExtension();
|
||||
|
||||
fgdFile->Printf( "@PointClass " );
|
||||
|
||||
#if 0
|
||||
if( bounds.GetVolume() > 0 )
|
||||
{
|
||||
fgdFile->Printf( "size(%i %i %i, %i %i %i) ",
|
||||
int( bounds[0].x ), int( bounds[0].y ), int( bounds[0].z ),
|
||||
int( bounds[1].x ), int( bounds[1].y ), int( bounds[1].z ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
fgdFile->Printf( "base(auto_generated_model) model({ \"path\": \"%s\" }) = %s : \"Just a model\" []\n", exportedModelFileName.c_str(), entityName.c_str() );
|
||||
//fgdFile->Printf( "[\n\t angles(string) : \"\" : \"0 0 0\"\n]\n\n", exportedModelFileName.c_str() );
|
||||
|
||||
totalEntitiesCount++;
|
||||
}
|
||||
|
||||
|
||||
totalModelsCount++;
|
||||
}
|
||||
fileSystem->FreeFileList( files );
|
||||
|
||||
com_editors &= ~EDITOR_EXPORTDEFS;
|
||||
postLoadExportModels.SetBool( false );
|
||||
|
||||
fgdFile->Flush();
|
||||
|
||||
common->Printf( "\nFGD written to %s\n", fgdFileName.c_str() );
|
||||
common->Printf( "----------------------------\n" );
|
||||
common->Printf( "Wrote %d Entities.\n", totalEntitiesCount );
|
||||
common->Printf( "Wrote %d Models.\n", totalModelsCount );
|
||||
|
||||
common->FatalError( "Exporting successful, need to restart manually" );
|
||||
|
|
Loading…
Reference in a new issue