mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
Dump materials in zone gdt
This commit is contained in:
parent
5ee541c0ff
commit
bc91738ee9
@ -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;
|
||||||
@ -1259,7 +1257,7 @@ namespace IW4
|
|||||||
const auto colorMapTexture = m_material->textureTable[colorMapIndex].u.image;
|
const auto colorMapTexture = m_material->textureTable[colorMapIndex].u.image;
|
||||||
const auto detailMapTexture = m_material->textureTable[detailMapIndex].u.image;
|
const auto detailMapTexture = m_material->textureTable[detailMapIndex].u.image;
|
||||||
|
|
||||||
if(colorMapTexture->width != 0 && colorMapTexture->height != 0
|
if (colorMapTexture->width != 0 && colorMapTexture->height != 0
|
||||||
&& detailMapTexture->width != 0 && detailMapTexture->height != 0)
|
&& detailMapTexture->width != 0 && detailMapTexture->height != 0)
|
||||||
{
|
{
|
||||||
const auto detailScaleFactorX = static_cast<float>(colorMapTexture->width) / static_cast<float>(detailMapTexture->width);
|
const auto detailScaleFactorX = static_cast<float>(colorMapTexture->width) / static_cast<float>(detailMapTexture->width);
|
||||||
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user