mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 06:34:10 +00:00
Autoremove rotation keyword for TrenchBroom
This commit is contained in:
parent
3cc6c0744e
commit
c104fff7ea
2 changed files with 93 additions and 96 deletions
|
@ -2744,73 +2744,44 @@ void idDeclManagerLocal::ExportModelsToTrenchBroom_f( const idCmdArgs& args )
|
|||
|
||||
int totalModelsCount = 0;
|
||||
|
||||
idFileList* files = fileSystem->ListFilesTree( "generated", ".blwo|.base|.bmd5mesh", true );
|
||||
|
||||
for( int f = 0; f < files->GetList().Num(); f++ )
|
||||
{
|
||||
idFileList* files;
|
||||
idStr modelName = files->GetList()[ f ];
|
||||
modelName.StripLeadingOnce( "generated/rendermodels/" );
|
||||
|
||||
files = fileSystem->ListFilesTree( "generated", ".blwo|.base|.bmd5mesh", true );
|
||||
for( int f = 0; f < files->GetList().Num(); f++ )
|
||||
idStr ext;
|
||||
modelName.ExtractFileExtension( ext );
|
||||
|
||||
if( ext.Icmp( "blwo" ) == 0 )
|
||||
{
|
||||
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++;
|
||||
modelName.SetFileExtension( "lwo" );
|
||||
}
|
||||
|
||||
fileSystem->FreeFileList( files );
|
||||
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() );
|
||||
|
||||
renderModelManager->FindModel( modelName );
|
||||
|
||||
totalModelsCount++;
|
||||
}
|
||||
fileSystem->FreeFileList( files );
|
||||
|
||||
com_editors &= ~EDITOR_EXPORTDEFS;
|
||||
postLoadExportModels.SetBool( false );
|
||||
|
||||
|
|
|
@ -2790,51 +2790,67 @@ bool idMapFile::ConvertToValve220Format()
|
|||
ent->epairs.Set( "_tb_textures", "textures/common;textures/editor;textures/decals;textures/decals2" );
|
||||
}
|
||||
|
||||
if( ent->GetNumPrimitives() > 0 )
|
||||
// build entity transform
|
||||
idVec3 origin;
|
||||
origin.Zero();
|
||||
|
||||
idMat3 rot;
|
||||
rot.Identity();
|
||||
|
||||
idStr name = ent->epairs.GetString( "name" );
|
||||
|
||||
origin = ent->epairs.GetVector( "origin", "0 0 0" );
|
||||
|
||||
if( !ent->epairs.GetMatrix( "rotation", "1 0 0 0 1 0 0 0 1", rot ) )
|
||||
{
|
||||
// build entity transform
|
||||
idVec3 origin;
|
||||
origin.Zero();
|
||||
idAngles angles;
|
||||
|
||||
idMat3 rot;
|
||||
rot.Identity();
|
||||
|
||||
idStr name = ent->epairs.GetString( "name" );
|
||||
|
||||
origin = ent->epairs.GetVector( "origin", "0 0 0" );
|
||||
|
||||
if( !ent->epairs.GetMatrix( "rotation", "1 0 0 0 1 0 0 0 1", rot ) )
|
||||
if( ent->epairs.GetAngles( "angles", "0 0 0", angles ) )
|
||||
{
|
||||
idAngles angles;
|
||||
|
||||
if( ent->epairs.GetAngles( "angles", "0 0 0", angles ) )
|
||||
if( angles.pitch != 0.0f || angles.yaw != 0.0f || angles.roll != 0.0f )
|
||||
{
|
||||
if( angles.pitch != 0.0f || angles.yaw != 0.0f || angles.roll != 0.0f )
|
||||
{
|
||||
rot = angles.ToMat3();
|
||||
}
|
||||
else
|
||||
{
|
||||
rot.Identity();
|
||||
}
|
||||
rot = angles.ToMat3();
|
||||
}
|
||||
else
|
||||
{
|
||||
float angle = ent->epairs.GetFloat( "angle" );
|
||||
if( angle != 0.0f )
|
||||
{
|
||||
rot = idAngles( 0.0f, angle, 0.0f ).ToMat3();
|
||||
}
|
||||
else
|
||||
{
|
||||
rot.Identity();
|
||||
}
|
||||
rot.Identity();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float angle = ent->epairs.GetFloat( "angle" );
|
||||
if( angle != 0.0f )
|
||||
{
|
||||
rot = idAngles( 0.0f, angle, 0.0f ).ToMat3();
|
||||
}
|
||||
else
|
||||
{
|
||||
rot.Identity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
idMat4 transform( rot, origin );
|
||||
//transform.Identity();
|
||||
idMat4 transform( rot, origin );
|
||||
//transform.Identity();
|
||||
|
||||
const idKeyValue* modelPair = ent->epairs.FindKey( "model" );
|
||||
idStr model = ent->epairs.GetString( "model" );
|
||||
#if 1
|
||||
// HACK: convert every old .lwo, .ase model to .obj
|
||||
idStr ext;
|
||||
model.ExtractFileExtension( ext );
|
||||
|
||||
if( ext.Icmp( "lwo" ) == 0 || ext.Icmp( "ase" ) == 0 || ext.Icmp( "dae" ) == 0 )
|
||||
{
|
||||
model.SetFileExtension( "obj" );
|
||||
model = "_tb/" + model;
|
||||
|
||||
ent->epairs.Set( "model", model );
|
||||
}
|
||||
#endif
|
||||
// is this oldschool brushes & patches?
|
||||
if( ent->GetNumPrimitives() > 0 )
|
||||
{
|
||||
#if 1
|
||||
if( !transform.IsIdentity() &&
|
||||
idStr::Icmp( classname, "func_static" ) != 0 &&
|
||||
|
@ -2847,7 +2863,6 @@ bool idMapFile::ConvertToValve220Format()
|
|||
}
|
||||
#endif
|
||||
|
||||
idStr model = ent->epairs.GetString( "model" );
|
||||
if( idStr::Icmp( classname, "func_static" ) == 0 && idStr::Icmp( model.c_str(), classname.c_str() ) == 0 )
|
||||
{
|
||||
ent->epairs.Delete( "model" );
|
||||
|
@ -2887,6 +2902,17 @@ bool idMapFile::ConvertToValve220Format()
|
|||
}
|
||||
else
|
||||
{
|
||||
// just a regular entity
|
||||
|
||||
// replace "rotation" with angles because it is not supported by TrenchBroom
|
||||
if( ent->epairs.FindKey( "rotation" ) )
|
||||
{
|
||||
ent->epairs.Delete( "rotation" );
|
||||
|
||||
idAngles angles = rot.ToAngles();
|
||||
ent->epairs.SetAngles( "angles", angles );
|
||||
}
|
||||
|
||||
const idKeyValue* kv = classTypeOverview.FindKey( classname );
|
||||
if( kv && kv->GetValue().Length() )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue