diff --git a/src/ObjWriting/Game/IW3/Material/DumperMaterialIW3.cpp b/src/ObjWriting/Game/IW3/Material/DumperMaterialIW3.cpp deleted file mode 100644 index bb3a87a8..00000000 --- a/src/ObjWriting/Game/IW3/Material/DumperMaterialIW3.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "DumperMaterialIW3.h" - -#include "Game/IW3/Material/JsonMaterialWriterIW3.h" -#include "Game/IW3/Material/MaterialConstantZoneStateIW3.h" -#include "Material/MaterialCommon.h" - -using namespace IW3; - -void AssetDumperMaterial::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - auto* materialConstantState = context.GetZoneAssetDumperState(); - materialConstantState->ExtractNamesFromZone(); - - AbstractAssetDumper::DumpPool(context, pool); -} - -bool AssetDumperMaterial::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto assetFile = context.OpenAssetFile(material::GetFileNameForAssetName(asset->m_name)); - - if (!assetFile) - return; - - DumpMaterialAsJson(*assetFile, *asset->Asset(), context); -} diff --git a/src/ObjWriting/Game/IW3/Material/DumperMaterialIW3.h b/src/ObjWriting/Game/IW3/Material/DumperMaterialIW3.h deleted file mode 100644 index 8438f6af..00000000 --- a/src/ObjWriting/Game/IW3/Material/DumperMaterialIW3.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW3/IW3.h" - -namespace IW3 -{ - class AssetDumperMaterial final : public AbstractAssetDumper - { - public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW3 diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp index 9149fc70..5aa9db1d 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp @@ -1,11 +1,11 @@ #include "ObjWriterIW3.h" #include "Game/IW3/GameAssetPoolIW3.h" +#include "Game/IW3/Material/MaterialJsonDumperIW3.h" #include "Game/IW3/XModel/XModelDumperIW3.h" #include "Image/ImageDumperIW3.h" #include "Localize/LocalizeDumperIW3.h" #include "Maps/MapEntsDumperIW3.h" -#include "Material/DumperMaterialIW3.h" #include "ObjWriting.h" #include "RawFile/AssetDumperRawFile.h" #include "Sound/AssetDumperLoadedSound.h" @@ -28,7 +28,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) // DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) diff --git a/src/ObjWriting/Game/IW4/Material/DecompilingMaterialDumperIW4.h b/src/ObjWriting/Game/IW4/Material/DecompilingMaterialDumperIW4.h deleted file mode 100644 index c6792591..00000000 --- a/src/ObjWriting/Game/IW4/Material/DecompilingMaterialDumperIW4.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "Dumping/AssetDumpingContext.h" -#include "Game/IW4/IW4.h" -#include "Obj/Gdt/GdtStream.h" - -namespace IW4 -{ - void DecompileMaterialToGdt(GdtOutputStream& out, const Material& material, AssetDumpingContext& context); -} // namespace IW4 diff --git a/src/ObjWriting/Game/IW4/Material/DumperMaterialIW4.cpp b/src/ObjWriting/Game/IW4/Material/DumperMaterialIW4.cpp deleted file mode 100644 index 9d10c301..00000000 --- a/src/ObjWriting/Game/IW4/Material/DumperMaterialIW4.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "DumperMaterialIW4.h" - -#include "DecompilingMaterialDumperIW4.h" -#include "Game/IW4/Material/JsonMaterialWriterIW4.h" -#include "Game/IW4/Material/MaterialConstantZoneStateIW4.h" -#include "Material/MaterialCommon.h" - -using namespace IW4; - -void AssetDumperMaterial::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - auto* materialConstantState = context.GetZoneAssetDumperState(); - materialConstantState->ExtractNamesFromZone(); - - AbstractAssetDumper::DumpPool(context, pool); -} - -bool AssetDumperMaterial::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ -#ifdef EXPERIMENTAL_MATERIAL_COMPILATION - if (context.m_gdt) - { - DecompileMaterialToGdt(*context.m_gdt, *asset->Asset(), context); - } -#else - const auto assetFile = context.OpenAssetFile(material::GetFileNameForAssetName(asset->m_name)); - - if (!assetFile) - return; - - DumpMaterialAsJson(*assetFile, *asset->Asset(), context); -#endif -} diff --git a/src/ObjWriting/Game/IW4/Material/DecompilingMaterialDumperIW4.cpp b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp similarity index 99% rename from src/ObjWriting/Game/IW4/Material/DecompilingMaterialDumperIW4.cpp rename to src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp index e6a5443d..21ca149e 100644 --- a/src/ObjWriting/Game/IW4/Material/DecompilingMaterialDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp @@ -1,4 +1,4 @@ -#include "DecompilingMaterialDumperIW4.h" +#include "MaterialDecompilingDumperIW4.h" #include "Game/IW4/MaterialConstantsIW4.h" #include "Game/IW4/ObjConstantsIW4.h" @@ -1108,11 +1108,19 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::material { - void DecompileMaterialToGdt(GdtOutputStream& out, const Material& material, AssetDumpingContext& context) + bool DecompilingGdtDumper::ShouldDump(XAssetInfo* asset) { - MaterialGdtDumper dumper(material); - out.WriteEntry(dumper.CreateGdtEntry()); + return true; } -} // namespace IW4 + + void DecompilingGdtDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + if (!context.m_gdt) + return; + + MaterialGdtDumper dumper(*asset->Asset()); + context.m_gdt->WriteEntry(dumper.CreateGdtEntry()); + } +} // namespace IW4::material diff --git a/src/ObjWriting/Game/IW4/Material/DumperMaterialIW4.h b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.h similarity index 55% rename from src/ObjWriting/Game/IW4/Material/DumperMaterialIW4.h rename to src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.h index 1d3447f3..dd192116 100644 --- a/src/ObjWriting/Game/IW4/Material/DumperMaterialIW4.h +++ b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.h @@ -3,15 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4 +namespace IW4::material { - class AssetDumperMaterial final : public AbstractAssetDumper + class DecompilingGdtDumper final : public AbstractAssetDumper { - public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::material diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 417ec52b..d14504d6 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -1,13 +1,14 @@ #include "ObjWriterIW4.h" #include "Game/IW4/GameAssetPoolIW4.h" +#include "Game/IW4/Material/MaterialJsonDumperIW4.h" #include "Game/IW4/XModel/XModelDumperIW4.h" #include "Image/ImageDumperIW4.h" #include "Leaderboard/LeaderboardJsonDumperIW4.h" #include "LightDef/LightDefDumperIW4.h" #include "Localize/LocalizeDumperIW4.h" #include "Maps/AddonMapEntsDumperIW4.h" -#include "Material/DumperMaterialIW4.h" +#include "Material/MaterialDecompilingDumperIW4.h" #include "Menu/AssetDumperMenuDef.h" #include "Menu/AssetDumperMenuList.h" #include "ObjWriting.h" @@ -42,7 +43,10 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) +#ifdef EXPERIMENTAL_MATERIAL_COMPILATION + DUMP_ASSET_POOL(material::DecompilingGdtDumper, m_material, ASSET_TYPE_MATERIAL) +#endif DUMP_ASSET_POOL(AssetDumperPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER) DUMP_ASSET_POOL(AssetDumperVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) diff --git a/src/ObjWriting/Game/IW5/Material/DumperMaterialIW5.cpp b/src/ObjWriting/Game/IW5/Material/DumperMaterialIW5.cpp deleted file mode 100644 index b8e705cb..00000000 --- a/src/ObjWriting/Game/IW5/Material/DumperMaterialIW5.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "DumperMaterialIW5.h" - -#include "Game/IW5/Material/JsonMaterialWriterIW5.h" -#include "Game/IW5/Material/MaterialConstantZoneStateIW5.h" -#include "Material/MaterialCommon.h" - -using namespace IW5; - -void AssetDumperMaterial::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - auto* materialConstantState = context.GetZoneAssetDumperState(); - materialConstantState->ExtractNamesFromZone(); - - AbstractAssetDumper::DumpPool(context, pool); -} - -bool AssetDumperMaterial::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto assetFile = context.OpenAssetFile(material::GetFileNameForAssetName(asset->m_name)); - - if (!assetFile) - return; - - const auto* material = asset->Asset(); - DumpMaterialAsJson(*assetFile, *material, context); -} diff --git a/src/ObjWriting/Game/IW5/Material/DumperMaterialIW5.h b/src/ObjWriting/Game/IW5/Material/DumperMaterialIW5.h deleted file mode 100644 index 12e57790..00000000 --- a/src/ObjWriting/Game/IW5/Material/DumperMaterialIW5.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW5/IW5.h" - -namespace IW5 -{ - class AssetDumperMaterial final : public AbstractAssetDumper - { - public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW5 diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index b08d609f..2e735cb7 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -1,12 +1,12 @@ #include "ObjWriterIW5.h" #include "Game/IW5/GameAssetPoolIW5.h" +#include "Game/IW5/Material/MaterialJsonDumperIW5.h" #include "Game/IW5/XModel/XModelDumperIW5.h" #include "Image/ImageDumperIW5.h" #include "Leaderboard/LeaderboardJsonDumperIW5.h" #include "Localize/LocalizeDumperIW5.h" #include "Maps/AddonMapEntsDumperIW5.h" -#include "Material/DumperMaterialIW5.h" #include "Menu/AssetDumperMenuDef.h" #include "Menu/AssetDumperMenuList.h" #include "ObjWriting.h" @@ -34,7 +34,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) // DUMP_ASSET_POOL(AssetDumperXModelSurfs, m_xmodel_surfs, ASSET_TYPE_XMODEL_SURFS) DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) // DUMP_ASSET_POOL(AssetDumperMaterialPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER) // DUMP_ASSET_POOL(AssetDumperMaterialVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) // DUMP_ASSET_POOL(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl, ASSET_TYPE_VERTEXDECL) diff --git a/src/ObjWriting/Game/T5/Material/DumperMaterialT5.cpp b/src/ObjWriting/Game/T5/Material/DumperMaterialT5.cpp deleted file mode 100644 index dcc6feb8..00000000 --- a/src/ObjWriting/Game/T5/Material/DumperMaterialT5.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "DumperMaterialT5.h" - -#include "Game/T5/Material/JsonMaterialWriterT5.h" -#include "Game/T5/Material/MaterialConstantZoneStateT5.h" -#include "Material/MaterialCommon.h" - -#include - -using namespace T5; - -void AssetDumperMaterial::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - auto* materialConstantState = context.GetZoneAssetDumperState(); - materialConstantState->ExtractNamesFromZone(); - - AbstractAssetDumper::DumpPool(context, pool); -} - -bool AssetDumperMaterial::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto assetFile = context.OpenAssetFile(material::GetFileNameForAssetName(asset->m_name)); - - if (!assetFile) - return; - - const auto* material = asset->Asset(); - assert(material->info.gameFlags < 0x400); - assert(material->maxStreamedMips == 0); - DumpMaterialAsJson(*assetFile, *material, context); -} diff --git a/src/ObjWriting/Game/T5/Material/DumperMaterialT5.h b/src/ObjWriting/Game/T5/Material/DumperMaterialT5.h deleted file mode 100644 index bb13565c..00000000 --- a/src/ObjWriting/Game/T5/Material/DumperMaterialT5.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/T5/T5.h" - -namespace T5 -{ - class AssetDumperMaterial final : public AbstractAssetDumper - { - public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace T5 diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index 7528ea67..1660e0d1 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -1,10 +1,10 @@ #include "ObjWriterT5.h" #include "Game/T5/GameAssetPoolT5.h" +#include "Game/T5/Material/MaterialJsonDumperT5.h" #include "Game/T5/XModel/XModelDumperT5.h" #include "Image/ImageDumperT5.h" #include "Localize/LocalizeDumperT5.h" -#include "Material/DumperMaterialT5.h" #include "ObjWriting.h" #include "PhysConstraints/AssetDumperPhysConstraints.h" #include "PhysPreset/AssetDumperPhysPreset.h" @@ -31,7 +31,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) // DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND) diff --git a/src/ObjWriting/Game/T6/Material/DumperMaterialT6.cpp b/src/ObjWriting/Game/T6/Material/DumperMaterialT6.cpp deleted file mode 100644 index 56e11e97..00000000 --- a/src/ObjWriting/Game/T6/Material/DumperMaterialT6.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "DumperMaterialT6.h" - -#include "Game/T6/Material/JsonMaterialWriterT6.h" -#include "Game/T6/Material/MaterialConstantZoneStateT6.h" -#include "Material/MaterialCommon.h" - -#include - -using namespace T6; - -void AssetDumperMaterial::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - auto* materialConstantState = context.GetZoneAssetDumperState(); - materialConstantState->ExtractNamesFromZone(); - - AbstractAssetDumper::DumpPool(context, pool); -} - -bool AssetDumperMaterial::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto assetFile = context.OpenAssetFile(material::GetFileNameForAssetName(asset->m_name)); - - if (!assetFile) - return; - - const auto* material = asset->Asset(); - assert(material->info.gameFlags < 0x8000); - assert(material->info.hashIndex == 0); - assert(material->probeMipBits == 0); - DumpMaterialAsJson(*assetFile, *material, context); -} diff --git a/src/ObjWriting/Game/T6/Material/DumperMaterialT6.h b/src/ObjWriting/Game/T6/Material/DumperMaterialT6.h deleted file mode 100644 index 99de31e7..00000000 --- a/src/ObjWriting/Game/T6/Material/DumperMaterialT6.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/T6/T6.h" - -namespace T6 -{ - class AssetDumperMaterial final : public AbstractAssetDumper - { - public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace T6 diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 54dc5056..c32e8ac0 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -2,12 +2,12 @@ #include "FontIcon/FontIconDumperT6.h" #include "Game/T6/GameAssetPoolT6.h" +#include "Game/T6/Material/MaterialJsonDumperT6.h" #include "Game/T6/XModel/XModelDumperT6.h" #include "Image/ImageDumperT6.h" #include "Leaderboard/LeaderboardJsonDumperT6.h" #include "Localize/LocalizeDumperT6.h" #include "Maps/MapEntsDumperT6.h" -#include "Material/DumperMaterialT6.h" #include "ObjWriting.h" #include "PhysConstraints/AssetDumperPhysConstraints.h" #include "PhysPreset/AssetDumperPhysPreset.h" @@ -51,7 +51,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND) diff --git a/src/ObjWriting/Material/JsonMaterialWriter.h.template b/src/ObjWriting/Material/JsonMaterialWriter.h.template deleted file mode 100644 index 277c5420..00000000 --- a/src/ObjWriting/Material/JsonMaterialWriter.h.template +++ /dev/null @@ -1,20 +0,0 @@ -#options GAME (IW3, IW4, IW5, T5, T6) - -#filename "Game/" + GAME + "/Material/JsonMaterialWriter" + GAME + ".h" - -// This file was templated. -// See JsonMaterialWriter.h.template. -// Do not modify, changes will be lost. - -#pragma once - -#include "Dumping/AssetDumpingContext.h" -#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\"" -#include GAME_HEADER - -#include - -namespace GAME -{ - void DumpMaterialAsJson(std::ostream& stream, const Material& material, AssetDumpingContext& context); -} // namespace GAME diff --git a/src/ObjWriting/Material/JsonMaterialWriter.cpp.template b/src/ObjWriting/Material/MaterialJsonDumper.cpp.template similarity index 90% rename from src/ObjWriting/Material/JsonMaterialWriter.cpp.template rename to src/ObjWriting/Material/MaterialJsonDumper.cpp.template index 4cce4829..817788f0 100644 --- a/src/ObjWriting/Material/JsonMaterialWriter.cpp.template +++ b/src/ObjWriting/Material/MaterialJsonDumper.cpp.template @@ -1,6 +1,6 @@ #options GAME (IW3, IW4, IW5, T5, T6) -#filename "Game/" + GAME + "/Material/JsonMaterialWriter" + GAME + ".cpp" +#filename "Game/" + GAME + "/Material/MaterialJsonDumper" + GAME + ".cpp" #if GAME == "IW3" #define FEATURE_IW3 @@ -24,16 +24,17 @@ #endif // This file was templated. -// See JsonMaterialWriter.cpp.template. +// See MaterialJsonDumper.cpp.template. // Do not modify, changes will be lost. -#set WRITER_HEADER "\"JsonMaterialWriter" + GAME + ".h\"" +#set WRITER_HEADER "\"MaterialJsonDumper" + GAME + ".h\"" #include WRITER_HEADER #ifdef HAS_WATER #include "Base64.h" #endif +#include "Material/MaterialCommon.h" #set COMMON_HEADER "\"Game/" + GAME + "/Common" + GAME + ".h\"" #include COMMON_HEADER #set JSON_HEADER "\"Game/" + GAME + "/Material/JsonMaterial" + GAME + ".h\"" @@ -41,18 +42,20 @@ #set CONSTANTS_HEADER "\"Game/" + GAME + "/Material/MaterialConstantZoneState" + GAME + ".h\"" #include CONSTANTS_HEADER +#include #include #include using namespace nlohmann; using namespace GAME; +using namespace ::material; namespace { - class JsonDumper + class JsonDumperImpl { public: - JsonDumper(AssetDumpingContext& context, std::ostream& stream) + JsonDumperImpl(AssetDumpingContext& context, std::ostream& stream) : m_stream(stream), m_material_constants(*context.GetZoneAssetDumperState()) { @@ -355,11 +358,40 @@ namespace }; } // namespace -namespace GAME +namespace GAME::material { - void DumpMaterialAsJson(std::ostream& stream, const Material& material, AssetDumpingContext& context) + void JsonDumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) { - const JsonDumper dumper(context, stream); - dumper.Dump(material); + auto* materialConstantState = context.GetZoneAssetDumperState(); + materialConstantState->ExtractNamesFromZone(); + + AbstractAssetDumper::DumpPool(context, pool); } -} // namespace GAME + + bool JsonDumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + const auto* material = asset->Asset(); +#if defined(FEATURE_T5) + assert(material->info.gameFlags < 0x400); + assert(material->maxStreamedMips == 0); +#elif defined(FEATURE_T6) + assert(material->info.gameFlags < 0x8000); + assert(material->info.hashIndex == 0); + assert(material->probeMipBits == 0); +#endif + + JsonDumperImpl dumper(context, *assetFile); + dumper.Dump(*material); + } +} // namespace T6::leaderboard + diff --git a/src/ObjWriting/Material/MaterialJsonDumper.h.template b/src/ObjWriting/Material/MaterialJsonDumper.h.template new file mode 100644 index 00000000..a9677b77 --- /dev/null +++ b/src/ObjWriting/Material/MaterialJsonDumper.h.template @@ -0,0 +1,27 @@ +#options GAME(IW3, IW4, IW5, T5, T6) + +#filename "Game/" + GAME + "/Material/MaterialJsonDumper" + GAME + ".h" + +// This file was templated. +// See MaterialJsonDumper.h.template. +// Do not modify, changes will be lost. + +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Dumping/AssetDumpingContext.h" +#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\"" +#include GAME_HEADER + +namespace GAME::material +{ + class JsonDumper final : public AbstractAssetDumper + { + public: + void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; + + protected: + [[nodiscard]] bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace GAME::material diff --git a/test/ObjWritingTests.lua b/test/ObjWritingTests.lua index 8afcba6c..cda98707 100644 --- a/test/ObjWritingTests.lua +++ b/test/ObjWritingTests.lua @@ -3,6 +3,7 @@ ObjWritingTests = {} function ObjWritingTests:include(includes) if includes:handle(self:name()) then includedirs { + "%{wks.location}/src/ObjWriting", path.join(TestFolder(), "ObjWritingTests") } end diff --git a/test/ObjWritingTests/Game/IW3/Material/DumperMaterialIW3Test.cpp b/test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3.cpp similarity index 99% rename from test/ObjWritingTests/Game/IW3/Material/DumperMaterialIW3Test.cpp rename to test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3.cpp index 077cbe13..e09856ba 100644 --- a/test/ObjWritingTests/Game/IW3/Material/DumperMaterialIW3Test.cpp +++ b/test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3.cpp @@ -1,4 +1,4 @@ -#include "Game/IW3/Material/DumperMaterialIW3.h" +#include "Game/IW3/Material/MaterialJsonDumperIW3.h" #include "Asset/AssetRegistration.h" #include "Game/IW3/CommonIW3.h" @@ -562,7 +562,7 @@ namespace GivenMaterial("wc/ch_plasterwall_long", materialPool, memory); - AssetDumperMaterial dumper; + material::JsonDumper dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/wc/ch_plasterwall_long.json"); diff --git a/test/ObjWritingTests/Game/IW4/Material/DumperMaterialIW4Test.cpp b/test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4.cpp similarity index 99% rename from test/ObjWritingTests/Game/IW4/Material/DumperMaterialIW4Test.cpp rename to test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4.cpp index 39b264a7..c2268aff 100644 --- a/test/ObjWritingTests/Game/IW4/Material/DumperMaterialIW4Test.cpp +++ b/test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4.cpp @@ -1,4 +1,4 @@ -#include "Game/IW4/Material/DumperMaterialIW4.h" +#include "Game/IW4/Material/MaterialJsonDumperIW4.h" #include "Asset/AssetRegistration.h" #include "Game/IW4/CommonIW4.h" @@ -543,7 +543,7 @@ namespace GivenMaterial("mc/ch_rubble01", materialPool, memory); - AssetDumperMaterial dumper; + material::JsonDumper dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/mc/ch_rubble01.json"); diff --git a/test/ObjWritingTests/Game/IW5/Material/DumperMaterialIW5Test.cpp b/test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5.cpp similarity index 99% rename from test/ObjWritingTests/Game/IW5/Material/DumperMaterialIW5Test.cpp rename to test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5.cpp index f8c15582..a40a1e2e 100644 --- a/test/ObjWritingTests/Game/IW5/Material/DumperMaterialIW5Test.cpp +++ b/test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5.cpp @@ -1,4 +1,4 @@ -#include "Game/IW5/Material/DumperMaterialIW5.h" +#include "Game/IW5/Material/MaterialJsonDumperIW5.h" #include "Asset/AssetRegistration.h" #include "Game/IW5/CommonIW5.h" @@ -596,7 +596,7 @@ namespace GivenMaterial("wc/me_metal_rust_02", materialPool, memory); - AssetDumperMaterial dumper; + material::JsonDumper dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/wc/me_metal_rust_02.json"); diff --git a/test/ObjWritingTests/Game/T5/Material/DumperMaterialT5Test.cpp b/test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5.cpp similarity index 99% rename from test/ObjWritingTests/Game/T5/Material/DumperMaterialT5Test.cpp rename to test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5.cpp index 4cc56013..aa5d230b 100644 --- a/test/ObjWritingTests/Game/T5/Material/DumperMaterialT5Test.cpp +++ b/test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5.cpp @@ -1,4 +1,4 @@ -#include "Game/T5/Material/DumperMaterialT5.h" +#include "Game/T5/Material/MaterialJsonDumperT5.h" #include "Asset/AssetRegistration.h" #include "Game/T5/CommonT5.h" @@ -625,7 +625,7 @@ namespace GivenMaterial("mc/ch_rubble01", materialPool, memory); - AssetDumperMaterial dumper; + material::JsonDumper dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/mc/ch_rubble01.json"); diff --git a/test/ObjWritingTests/Game/T6/Material/DumperMaterialT6Test.cpp b/test/ObjWritingTests/Game/T6/Material/MaterialJsonDumperT6Test.cpp similarity index 99% rename from test/ObjWritingTests/Game/T6/Material/DumperMaterialT6Test.cpp rename to test/ObjWritingTests/Game/T6/Material/MaterialJsonDumperT6Test.cpp index 2586760d..db8dc42a 100644 --- a/test/ObjWritingTests/Game/T6/Material/DumperMaterialT6Test.cpp +++ b/test/ObjWritingTests/Game/T6/Material/MaterialJsonDumperT6Test.cpp @@ -1,4 +1,4 @@ -#include "Game/T6/Material/DumperMaterialT6.h" +#include "Game/T6/Material/MaterialJsonDumperT6.h" #include "Asset/AssetRegistration.h" #include "Game/T6/CommonT6.h" @@ -472,7 +472,7 @@ namespace AssetPoolDynamic materialPool(0); GivenMaterial("wpc/metal_ac_duct", materialPool, memory); - AssetDumperMaterial dumper; + material::JsonDumper dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/wpc/metal_ac_duct.json");