mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-22 09:40:46 +00:00
Added small hack to load autogenerated genmodel_ entities
This commit is contained in:
parent
920df3df63
commit
3de739ae32
6 changed files with 106 additions and 18 deletions
|
@ -2,8 +2,8 @@ entityDef misc_model
|
|||
{
|
||||
"inherit" "func_static"
|
||||
"editor_color" "0 .5 .8"
|
||||
"editor_mins" "-12 -12 -12"
|
||||
"editor_maxs" "12 12 12"
|
||||
"editor_mins" "?"
|
||||
"editor_maxs" "?"
|
||||
"editor_rotatable" "1"
|
||||
|
||||
"editor_usage" "Inherits from a func_static but uses a model and is a FGD PointClass so it displays correctly in TrenchBroom."
|
||||
|
|
|
@ -229,7 +229,7 @@ this is the canonical renderEntity parm parsing,
|
|||
which should be used by dmap and the editor
|
||||
================
|
||||
*/
|
||||
void idGameEdit::ParseSpawnArgsToRenderEntity( const idDict* args, renderEntity_t* renderEntity )
|
||||
void idGameEdit::ParseSpawnArgsToRenderEntity( const idDict* args, renderEntity_t* renderEntity, const idDeclEntityDef* def )
|
||||
{
|
||||
int i;
|
||||
const char* temp;
|
||||
|
@ -254,6 +254,33 @@ void idGameEdit::ParseSpawnArgsToRenderEntity( const idDict* args, renderEntity_
|
|||
renderEntity->hModel = renderModelManager->FindModel( temp );
|
||||
}
|
||||
}
|
||||
// RB: TrenchBroom interop
|
||||
else if( def != NULL )
|
||||
{
|
||||
// if the name starts with genmodel_ it means that it was generated by exportModelsToTrenchBroom
|
||||
// and we have a special entityDef for it in base/def/_tb_models.def
|
||||
|
||||
temp = args->GetString( "name" );
|
||||
if( idStr::Icmpn( temp, "genmodel_", 9 ) == 0 )
|
||||
{
|
||||
// grab the model key from the definition instead
|
||||
temp = def->dict.GetString( "model" );
|
||||
if( temp[0] != '\0' )
|
||||
{
|
||||
modelDef = static_cast<const idDeclModelDef*>( declManager->FindType( DECL_MODELDEF, temp, false ) );
|
||||
if( modelDef )
|
||||
{
|
||||
renderEntity->hModel = modelDef->ModelHandle();
|
||||
}
|
||||
if( !renderEntity->hModel )
|
||||
{
|
||||
renderEntity->hModel = renderModelManager->FindModel( temp );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// RB end
|
||||
|
||||
if( renderEntity->hModel )
|
||||
{
|
||||
renderEntity->bounds = renderEntity->hModel->Bounds( renderEntity );
|
||||
|
@ -637,7 +664,7 @@ void idEntity::Spawn()
|
|||
|
||||
health = spawnArgs.GetInt( "health" );
|
||||
|
||||
InitDefaultPhysics( origin, axis );
|
||||
InitDefaultPhysics( origin, axis, def );
|
||||
|
||||
SetOrigin( origin );
|
||||
SetAxis( axis );
|
||||
|
@ -652,6 +679,27 @@ void idEntity::Spawn()
|
|||
origin += GetOriginBrushOffset();
|
||||
SetOrigin( origin );
|
||||
}
|
||||
// RB: TrenchBroom interop
|
||||
else if( def != NULL )
|
||||
{
|
||||
// if the name starts with genmodel_ it means that it was generated by exportModelsToTrenchBroom
|
||||
// and we have a special entityDef for it in base/def/_tb_models.def
|
||||
if( idStr::Icmpn( name.c_str(), "genmodel_", 9 ) == 0 )
|
||||
{
|
||||
// grab the model key from the definition instead
|
||||
temp = def->dict.GetString( "model" );
|
||||
if( temp != NULL && *temp != '\0' )
|
||||
{
|
||||
SetModel( temp );
|
||||
|
||||
// Entities without models don't have origin brushes,
|
||||
// so it makes sense to apply this only IF there is a model
|
||||
origin += GetOriginBrushOffset();
|
||||
SetOrigin( origin );
|
||||
}
|
||||
}
|
||||
}
|
||||
// RB end
|
||||
|
||||
if( spawnArgs.GetString( "bind", "", &temp ) )
|
||||
{
|
||||
|
@ -2834,7 +2882,7 @@ void idEntity::QuitTeam()
|
|||
idEntity::InitDefaultPhysics
|
||||
================
|
||||
*/
|
||||
void idEntity::InitDefaultPhysics( const idVec3& origin, const idMat3& axis )
|
||||
void idEntity::InitDefaultPhysics( const idVec3& origin, const idMat3& axis, const idDeclEntityDef* def )
|
||||
{
|
||||
const char* temp;
|
||||
idClipModel* clipModel = NULL;
|
||||
|
@ -2910,6 +2958,25 @@ void idEntity::InitDefaultPhysics( const idVec3& origin, const idMat3& axis )
|
|||
clipModel = new( TAG_PHYSICS_CLIP_ENTITY ) idClipModel( temp );
|
||||
}
|
||||
}
|
||||
// RB: TrenchBroom interop
|
||||
else if( def != NULL )
|
||||
{
|
||||
// if the name starts with genmodel_ it means that it was generated by exportModelsToTrenchBroom
|
||||
// and we have a special entityDef for it in base/def/_tb_models.def
|
||||
if( idStr::Icmpn( name.c_str(), "genmodel_", 9 ) == 0 )
|
||||
{
|
||||
// grab the model key from the definition instead
|
||||
temp = def->dict.GetString( "model" );
|
||||
if( ( temp != NULL ) && ( *temp != 0 ) )
|
||||
{
|
||||
if( idClipModel::CheckModel( temp ) )
|
||||
{
|
||||
clipModel = new( TAG_PHYSICS_CLIP_ENTITY ) idClipModel( temp );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// RB end
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -556,7 +556,7 @@ private:
|
|||
|
||||
// physics
|
||||
// initialize the default physics
|
||||
void InitDefaultPhysics( const idVec3& origin, const idMat3& axis );
|
||||
void InitDefaultPhysics( const idVec3& origin, const idMat3& axis, const idDeclEntityDef* def );
|
||||
// update visual position from the physics
|
||||
void UpdateFromPhysics( bool moveBack );
|
||||
// get physics timestep
|
||||
|
|
|
@ -240,7 +240,7 @@ public:
|
|||
|
||||
// These are the canonical idDict to parameter parsing routines used by both the game and tools.
|
||||
virtual void ParseSpawnArgsToRenderLight( const idDict* args, renderLight_t* renderLight );
|
||||
virtual void ParseSpawnArgsToRenderEntity( const idDict* args, renderEntity_t* renderEntity );
|
||||
virtual void ParseSpawnArgsToRenderEntity( const idDict* args, renderEntity_t* renderEntity, const idDeclEntityDef* def = NULL );
|
||||
virtual void ParseSpawnArgsToRenderEnvprobe( const idDict* args, renderEnvironmentProbe_t* renderEnvprobe ); // RB
|
||||
virtual void ParseSpawnArgsToRefSound( const idDict* args, refSound_t* refSound );
|
||||
|
||||
|
|
|
@ -2988,6 +2988,7 @@ void idDeclManagerLocal::ExportModelsToTrenchBroom_f( const idCmdArgs& args )
|
|||
|
||||
idFileList* files = fileSystem->ListFilesTree( "generated", ".blwo|.base|.bmd5mesh", true, true );
|
||||
|
||||
// FGD header
|
||||
idStr fgdFileName;
|
||||
fgdFileName.Format( "exported/_tb/DOOM-3-models.fgd" );
|
||||
idFileLocal fgdFile( fileSystem->OpenFileWrite( fgdFileName, "fs_basepath" ) );
|
||||
|
@ -3014,13 +3015,24 @@ void idDeclManagerLocal::ExportModelsToTrenchBroom_f( const idCmdArgs& args )
|
|||
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" );
|
||||
|
||||
fgdFile->Printf( "@PointClass base(func_static) color(0 127 204) size(-12 -12 -12, 12 12 12) model({ \"path\" : proxymodel }) = misc_model : \"Just a model\"\n[\n" );
|
||||
fgdFile->Printf( "@PointClass base(func_static) color(0 127 204) model({ \"path\" : proxymodel }) = misc_model : \"Just a model\"\n[\n" );
|
||||
//fgdFile->Printf( "name(string) : \"\" : \"\"\n" );
|
||||
fgdFile->Printf( "\t angles(string) : \"\" : \"0 0 0\"\n" );
|
||||
fgdFile->Printf( "]\n\n" );
|
||||
|
||||
fgdFile->Printf( "@PointClass base(misc_model) = auto_generated_model : \"Entity definition for a specific model\" []\n\n" );
|
||||
|
||||
// DEF header
|
||||
idStr defFileName;
|
||||
defFileName.Format( "def/_tb_models.def" );
|
||||
idFileLocal defFile( fileSystem->OpenFileWrite( defFileName, "fs_basepath" ) );
|
||||
if( defFile == NULL )
|
||||
{
|
||||
common->Printf( "Failed to write entity declarations data to DEF.\n" );
|
||||
}
|
||||
|
||||
defFile->Printf( "// DOOM 3 BFG models definition file (.def) generated by %s\n\n", ENGINE_VERSION );
|
||||
|
||||
for( int f = 0; f < files->GetList().Num(); f++ )
|
||||
{
|
||||
totalModelsCount++;
|
||||
|
@ -3088,6 +3100,8 @@ void idDeclManagerLocal::ExportModelsToTrenchBroom_f( const idCmdArgs& args )
|
|||
}
|
||||
|
||||
idBounds bounds = renderModel->Bounds();
|
||||
bounds[0].Snap();
|
||||
bounds[1].Snap();
|
||||
|
||||
// put model as mapobject into the models FGD
|
||||
if( !renderModel->IsDefaultModel() && bounds.GetVolume() > 0 && bounds.GetRadius() < 1400 )
|
||||
|
@ -3101,7 +3115,7 @@ void idDeclManagerLocal::ExportModelsToTrenchBroom_f( const idCmdArgs& args )
|
|||
exportedModelFileName.SetFileExtension( ".obj" );
|
||||
|
||||
idStrStatic< MAX_OSPATH > entityName;
|
||||
|
||||
/*
|
||||
if( idStr::Icmpn( modelName, "models/mapobjects", 17 ) == 0 )
|
||||
{
|
||||
modelName.StripLeadingOnce( "models/mapobjects" );
|
||||
|
@ -3110,10 +3124,11 @@ void idDeclManagerLocal::ExportModelsToTrenchBroom_f( const idCmdArgs& args )
|
|||
entityName.AppendPath( modelName );
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
modelName.StripLeadingOnce( "models/" );
|
||||
modelName.StripLeadingOnce( "models" );
|
||||
|
||||
entityName = "mdl";
|
||||
entityName = "genmodel";
|
||||
entityName.AppendPath( modelName );
|
||||
}
|
||||
|
||||
|
@ -3125,7 +3140,7 @@ void idDeclManagerLocal::ExportModelsToTrenchBroom_f( const idCmdArgs& args )
|
|||
|
||||
fgdFile->Printf( "@PointClass " );
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
if( bounds.GetVolume() > 0 )
|
||||
{
|
||||
fgdFile->Printf( "size(%i %i %i, %i %i %i) ",
|
||||
|
@ -3140,6 +3155,16 @@ void idDeclManagerLocal::ExportModelsToTrenchBroom_f( const idCmdArgs& args )
|
|||
fgdFile->Printf( "\t model(string) : \"\" : \"%s\"\n", originalModelFileName.c_str() );
|
||||
fgdFile->Printf( "]\n\n", exportedModelFileName.c_str() );
|
||||
|
||||
|
||||
// write .def file for Doom
|
||||
//defFile->Printf( "base(auto_generated_model) model({ \"path\": \"%s\" }) = %s : \"Display entity\"\n[\n", exportedModelFileName.c_str(), entityName.c_str() );
|
||||
|
||||
defFile->Printf( "entityDef %s\n{\n", entityName.c_str() );
|
||||
defFile->Printf( "\t \"inherit\" \"misc_model\"\n" );
|
||||
defFile->Printf( "\t \"proxymodel\" \"%s\"\n", exportedModelFileName.c_str() );
|
||||
defFile->Printf( "\t \"model\" \"%s\"\n", originalModelFileName.c_str() );
|
||||
defFile->Printf( "}\n\n", exportedModelFileName.c_str() );
|
||||
|
||||
totalEntitiesCount++;
|
||||
}
|
||||
|
||||
|
@ -3633,8 +3658,6 @@ void idDeclManagerLocal::MakeZooMapForModels_f( const idCmdArgs& args )
|
|||
}
|
||||
|
||||
idBounds bounds = renderModel->Bounds();
|
||||
bounds[0].Snap();
|
||||
bounds[1].Snap();
|
||||
|
||||
// put model as mapobject into the models FGD
|
||||
if( !renderModel->IsDefaultModel() && bounds.GetVolume() > 0 && bounds.GetRadius() < 1400 )
|
||||
|
@ -3655,8 +3678,6 @@ void idDeclManagerLocal::MakeZooMapForModels_f( const idCmdArgs& args )
|
|||
mapEnt->epairs.Set( "name", entityName );
|
||||
mapEnt->epairs.Set( "proxymodel", exportedModelFileName );
|
||||
mapEnt->epairs.Set( "model", modelName );
|
||||
mapEnt->epairs.SetVector( "mins", bounds[0] );
|
||||
mapEnt->epairs.SetVector( "maxs", bounds[1] );
|
||||
|
||||
EntityInfo_t* entInfo = new( TAG_SYSTEM ) EntityInfo_t;
|
||||
entInfo->bounds = bounds;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
REM 7z a RBDOOM-3-BFG-1.3.1.1-lite-win64-20220109-git-xxxxxxx.7z -r base/env/ base/maps/*.lightgrid base/maps/*_extra_ents.map -x!generated
|
||||
set filename=RBDOOM-3-BFG-1.4.0.5-lite-win64-20220219-git-xxxxxxx.7z
|
||||
7z a %filename% README.md RELEASE-NOTES.md base/devtools.cfg base/modelviewer.cfg base/extract_resources.cfg base/convert_maps_to_valve220.cfg base/def/*.def base/materials/*.mtr base/textures/common base/textures/editor -x!generated -xr!*.xcf -xr!*.blend
|
||||
set filename=RBDOOM-3-BFG-1.4.0.6-lite-win64-20220227-git-xxxxxxx.7z
|
||||
7z a %filename% README.md RELEASE-NOTES.md base/devtools.cfg base/modelviewer.cfg base/extract_resources.cfg base/convert_maps_to_valve220.cfg base/def/*.def base/materials/*.mtr base/textures/common base/textures/editor base/maps/zoomaps -x!generated -xr!*.xcf -xr!*.blend
|
||||
7z a %filename% README.md RELEASE-NOTES.md tools/trenchbroom -xr!TrenchBroom-nomanual* -xr!TrenchBroom.pdb
|
||||
pause
|
||||
|
|
Loading…
Reference in a new issue