From 92c5cbf7582bcbce89b12fe1b01bc63026da539a Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Fri, 21 Jan 2022 18:33:42 +0100 Subject: [PATCH] convertMapToValve220 now works with just the .resource files --- neo/idlib/MapFile.cpp | 47 +++++++++++++++++++++++++----- neo/idlib/MapFile.h | 4 ++- neo/renderer/Material.cpp | 3 +- zip-RBDOOM-3-BFG-lite-snapshot.bat | 2 +- 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/neo/idlib/MapFile.cpp b/neo/idlib/MapFile.cpp index e468d243..184d84fb 100644 --- a/neo/idlib/MapFile.cpp +++ b/neo/idlib/MapFile.cpp @@ -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( 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 diff --git a/neo/idlib/MapFile.h b/neo/idlib/MapFile.h index 04549ec2..cd937338 100644 --- a/neo/idlib/MapFile.h +++ b/neo/idlib/MapFile.h @@ -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; diff --git a/neo/renderer/Material.cpp b/neo/renderer/Material.cpp index fe355550..862344ba 100644 --- a/neo/renderer/Material.cpp +++ b/neo/renderer/Material.cpp @@ -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 ) diff --git a/zip-RBDOOM-3-BFG-lite-snapshot.bat b/zip-RBDOOM-3-BFG-lite-snapshot.bat index 50a0d613..d4b6b250 100644 --- a/zip-RBDOOM-3-BFG-lite-snapshot.bat +++ b/zip-RBDOOM-3-BFG-lite-snapshot.bat @@ -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