convertMapToValve220 now works with just the .resource files

This commit is contained in:
Robert Beckebans 2022-01-21 18:33:42 +01:00
parent 0e8951bdbd
commit 92c5cbf758
4 changed files with 45 additions and 11 deletions

View file

@ -134,7 +134,7 @@ inline bool BrushPrimitive_Degenerate( const idVec3& bpTexMatX, const idVec3& bp
}
// heavily inspired by Valve220_from_BP from Netradiant-custom
void idMapBrushSide::ConvertToValve220Format( const idMat4& entityTransform )
void idMapBrushSide::ConvertToValve220Format( const idMat4& entityTransform, idStrList& textureCollections )
{
// create p1, p2, p3
idVec3 forward = plane.Normal();
@ -193,7 +193,7 @@ void idMapBrushSide::ConvertToValve220Format( const idMat4& entityTransform )
texValve[i].Normalize();
}
//material = "enpro/enwall16";
idMapFile::AddMaterialToCollection( GetMaterial(), textureCollections );
const idMaterial* material = declManager->FindMaterial( GetMaterial() );
@ -2776,6 +2776,7 @@ bool idMapFile::ConvertToValve220Format()
valve220Format = true;
idDict classTypeOverview;
idStrList textureCollections;
int count = GetNumEntities();
for( int j = 0; j < count; j++ )
@ -2785,11 +2786,6 @@ bool idMapFile::ConvertToValve220Format()
{
idStr classname = ent->epairs.GetString( "classname" );
if( idStr::Icmp( classname, "worldspawn" ) == 0 )
{
ent->epairs.Set( "_tb_textures", "textures/common;textures/editor;textures/decals;textures/decals2" );
}
// build entity transform
idVec3 origin;
origin.Zero();
@ -2880,9 +2876,14 @@ bool idMapFile::ConvertToValve220Format()
for( int s = 0; s < brushPrim->GetNumSides(); s++ )
{
idMapBrushSide* side = brushPrim->GetSide( s );
side->ConvertToValve220Format( transform );
side->ConvertToValve220Format( transform, textureCollections );
}
}
else if( mapPrim->GetType() == idMapPrimitive::TYPE_PATCH )
{
idMapPatch* patch = static_cast<idMapPatch*>( mapPrim );
idMapFile::AddMaterialToCollection( patch->GetMaterial(), textureCollections );
}
}
// collect some statistics
@ -2936,6 +2937,25 @@ bool idMapFile::ConvertToValve220Format()
}
}
idMapEntity* worldspawn = GetEntity( 0 );
if( worldspawn )
{
//worldspawn->epairs.Set( "_tb_textures", "textures/common;textures/editor;textures/decals;textures/decals2" );
idStr list;
for( int i = 0; i < textureCollections.Num(); i++ )
{
list += textureCollections[ i ];
if( i != ( textureCollections.Num() - 1 ) )
{
list += ";";
}
}
worldspawn->epairs.Set( "_tb_textures", list );
}
int n = classTypeOverview.GetNumKeyVals();
idLib::Printf( "BrushClasses:\n" );
@ -2974,4 +2994,15 @@ bool idMapFile::ConvertToValve220Format()
return true;
}
void idMapFile::AddMaterialToCollection( const char* material, idStrList& textureCollections )
{
idStr withoutPath = material;
withoutPath.StripPath();
idStr textureCollection = material;
textureCollection.StripTrailingOnce( "/" + withoutPath );
textureCollections.AddUnique( textureCollection );
}
// RB end

View file

@ -133,7 +133,7 @@ public:
return texSize;
}
void ConvertToValve220Format( const idMat4& entityTransform );
void ConvertToValve220Format( const idMat4& entityTransform, idStrList& textureCollections );
// RB end
protected:
@ -527,6 +527,8 @@ public:
return hasPrimitiveData;
}
static void AddMaterialToCollection( const char* material, idStrList& textureCollections );
protected:
float version;
ID_TIME_T fileTime;

View file

@ -247,7 +247,8 @@ idImage* idMaterial::GetEditorImage() const
else
{
// look for an explicit one
editorImage = globalImages->ImageFromFile( editorImageName, TF_DEFAULT, TR_REPEAT, TD_DEFAULT );
// RB: changed to TD_DIFFUSE because BFG didn't ship the editor images
editorImage = globalImages->ImageFromFile( editorImageName, TF_DEFAULT, TR_REPEAT, TD_DIFFUSE );
}
if( !editorImage )

View file

@ -1,3 +1,3 @@
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
7z a RBDOOM-3-BFG-1.3.1.1-lite-win64-20220109-git-xxxxxxx.7z 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/_tb -x!generated
7z a RBDOOM-3-BFG-1.3.1.1-lite-win64-20220109-git-xxxxxxx.7z 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/textures/common base/textures/editor -x!generated
pause