Dump materials in zone gdt

This commit is contained in:
Jan 2022-07-09 15:44:03 +02:00
parent 5ee541c0ff
commit bc91738ee9

View File

@ -12,8 +12,8 @@
#include "Game/IW4/TechsetConstantsIW4.h" #include "Game/IW4/TechsetConstantsIW4.h"
#include "Math/Vector.h" #include "Math/Vector.h"
#define DUMP_AS_JSON 1 //#define DUMP_AS_JSON 1
#define DUMP_AS_GDT 1 //#define DUMP_AS_GDT 1
//#define FLAGS_DEBUG 1 //#define FLAGS_DEBUG 1
using namespace IW4; using namespace IW4;
@ -609,8 +609,6 @@ namespace IW4
class MaterialGdtDumper class MaterialGdtDumper
{ {
std::ostream& m_stream;
TechsetInfo m_techset_info; TechsetInfo m_techset_info;
StateBitsInfo m_state_bits_info; StateBitsInfo m_state_bits_info;
ConstantsInfo m_constants_info; ConstantsInfo m_constants_info;
@ -1425,27 +1423,22 @@ namespace IW4
} }
public: public:
explicit MaterialGdtDumper(std::ostream& stream, const Material* material) explicit MaterialGdtDumper(const Material* material)
: m_stream(stream), : m_material(material)
m_material(material)
{ {
m_entry.m_gdf_name = "material.gdf";
m_entry.m_name = m_material->info.name;
} }
void CreateGdtEntry() GdtEntry& CreateGdtEntry()
{ {
m_entry = GdtEntry();
m_entry.m_gdf_name = "material.gdf";
m_entry.m_name = m_material->info.name;
SetCommonValues(); SetCommonValues();
SetMaterialTypeValues(); SetMaterialTypeValues();
SetTextureTableValues(); SetTextureTableValues();
}
void Dump() return m_entry;
{
Gdt gdt(GdtVersion("IW4", 1));
gdt.m_entries.emplace_back(std::make_unique<GdtEntry>(std::move(m_entry)));
GdtOutputStream::WriteGdt(gdt, m_stream);
} }
}; };
} }
@ -1479,9 +1472,18 @@ void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo<Mat
if (!assetFile) if (!assetFile)
return; return;
auto& stream = *assetFile; auto& stream = *assetFile;
MaterialGdtDumper dumper(stream, material); MaterialGdtDumper dumper(material);
dumper.CreateGdtEntry(); Gdt gdt(GdtVersion("IW4", 1));
dumper.Dump(); gdt.m_entries.emplace_back(std::make_unique<GdtEntry>(std::move(dumper.CreateGdtEntry())));
GdtOutputStream::WriteGdt(gdt, stream);
}
#endif
#if !defined(DUMP_AS_JSON) && !defined(DUMP_AS_GDT)
if (context.m_gdt)
{
MaterialGdtDumper dumper(material);
context.m_gdt->WriteEntry(dumper.CreateGdtEntry());
} }
#endif #endif
} }