mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-01 06:27:26 +00:00
refactor: streamline material dumping
This commit is contained in:
@@ -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<Material>* pool)
|
|
||||||
{
|
|
||||||
auto* materialConstantState = context.GetZoneAssetDumperState<MaterialConstantZoneState>();
|
|
||||||
materialConstantState->ExtractNamesFromZone();
|
|
||||||
|
|
||||||
AbstractAssetDumper::DumpPool(context, pool);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AssetDumperMaterial::ShouldDump(XAssetInfo<Material>* asset)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset)
|
|
||||||
{
|
|
||||||
const auto assetFile = context.OpenAssetFile(material::GetFileNameForAssetName(asset->m_name));
|
|
||||||
|
|
||||||
if (!assetFile)
|
|
||||||
return;
|
|
||||||
|
|
||||||
DumpMaterialAsJson(*assetFile, *asset->Asset(), context);
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Dumping/AbstractAssetDumper.h"
|
|
||||||
#include "Game/IW3/IW3.h"
|
|
||||||
|
|
||||||
namespace IW3
|
|
||||||
{
|
|
||||||
class AssetDumperMaterial final : public AbstractAssetDumper<Material>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void DumpPool(AssetDumpingContext& context, AssetPool<Material>* pool) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool ShouldDump(XAssetInfo<Material>* asset) override;
|
|
||||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset) override;
|
|
||||||
};
|
|
||||||
} // namespace IW3
|
|
@@ -1,11 +1,11 @@
|
|||||||
#include "ObjWriterIW3.h"
|
#include "ObjWriterIW3.h"
|
||||||
|
|
||||||
#include "Game/IW3/GameAssetPoolIW3.h"
|
#include "Game/IW3/GameAssetPoolIW3.h"
|
||||||
|
#include "Game/IW3/Material/MaterialJsonDumperIW3.h"
|
||||||
#include "Game/IW3/XModel/XModelDumperIW3.h"
|
#include "Game/IW3/XModel/XModelDumperIW3.h"
|
||||||
#include "Image/ImageDumperIW3.h"
|
#include "Image/ImageDumperIW3.h"
|
||||||
#include "Localize/LocalizeDumperIW3.h"
|
#include "Localize/LocalizeDumperIW3.h"
|
||||||
#include "Maps/MapEntsDumperIW3.h"
|
#include "Maps/MapEntsDumperIW3.h"
|
||||||
#include "Material/DumperMaterialIW3.h"
|
|
||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
#include "RawFile/AssetDumperRawFile.h"
|
#include "RawFile/AssetDumperRawFile.h"
|
||||||
#include "Sound/AssetDumperLoadedSound.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(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET)
|
||||||
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
|
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
|
||||||
DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL)
|
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(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
|
||||||
DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE)
|
DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE)
|
||||||
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
|
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
|
||||||
|
@@ -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
|
|
@@ -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<Material>* pool)
|
|
||||||
{
|
|
||||||
auto* materialConstantState = context.GetZoneAssetDumperState<MaterialConstantZoneState>();
|
|
||||||
materialConstantState->ExtractNamesFromZone();
|
|
||||||
|
|
||||||
AbstractAssetDumper::DumpPool(context, pool);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AssetDumperMaterial::ShouldDump(XAssetInfo<Material>* asset)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* 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
|
|
||||||
}
|
|
@@ -1,4 +1,4 @@
|
|||||||
#include "DecompilingMaterialDumperIW4.h"
|
#include "MaterialDecompilingDumperIW4.h"
|
||||||
|
|
||||||
#include "Game/IW4/MaterialConstantsIW4.h"
|
#include "Game/IW4/MaterialConstantsIW4.h"
|
||||||
#include "Game/IW4/ObjConstantsIW4.h"
|
#include "Game/IW4/ObjConstantsIW4.h"
|
||||||
@@ -1108,11 +1108,19 @@ namespace
|
|||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace IW4
|
namespace IW4::material
|
||||||
{
|
{
|
||||||
void DecompileMaterialToGdt(GdtOutputStream& out, const Material& material, AssetDumpingContext& context)
|
bool DecompilingGdtDumper::ShouldDump(XAssetInfo<Material>* asset)
|
||||||
{
|
{
|
||||||
MaterialGdtDumper dumper(material);
|
return true;
|
||||||
out.WriteEntry(dumper.CreateGdtEntry());
|
|
||||||
}
|
}
|
||||||
} // namespace IW4
|
|
||||||
|
void DecompilingGdtDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset)
|
||||||
|
{
|
||||||
|
if (!context.m_gdt)
|
||||||
|
return;
|
||||||
|
|
||||||
|
MaterialGdtDumper dumper(*asset->Asset());
|
||||||
|
context.m_gdt->WriteEntry(dumper.CreateGdtEntry());
|
||||||
|
}
|
||||||
|
} // namespace IW4::material
|
@@ -3,15 +3,12 @@
|
|||||||
#include "Dumping/AbstractAssetDumper.h"
|
#include "Dumping/AbstractAssetDumper.h"
|
||||||
#include "Game/IW4/IW4.h"
|
#include "Game/IW4/IW4.h"
|
||||||
|
|
||||||
namespace IW4
|
namespace IW4::material
|
||||||
{
|
{
|
||||||
class AssetDumperMaterial final : public AbstractAssetDumper<Material>
|
class DecompilingGdtDumper final : public AbstractAssetDumper<Material>
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
void DumpPool(AssetDumpingContext& context, AssetPool<Material>* pool) override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool ShouldDump(XAssetInfo<Material>* asset) override;
|
bool ShouldDump(XAssetInfo<Material>* asset) override;
|
||||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset) override;
|
void DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset) override;
|
||||||
};
|
};
|
||||||
} // namespace IW4
|
} // namespace IW4::material
|
@@ -1,13 +1,14 @@
|
|||||||
#include "ObjWriterIW4.h"
|
#include "ObjWriterIW4.h"
|
||||||
|
|
||||||
#include "Game/IW4/GameAssetPoolIW4.h"
|
#include "Game/IW4/GameAssetPoolIW4.h"
|
||||||
|
#include "Game/IW4/Material/MaterialJsonDumperIW4.h"
|
||||||
#include "Game/IW4/XModel/XModelDumperIW4.h"
|
#include "Game/IW4/XModel/XModelDumperIW4.h"
|
||||||
#include "Image/ImageDumperIW4.h"
|
#include "Image/ImageDumperIW4.h"
|
||||||
#include "Leaderboard/LeaderboardJsonDumperIW4.h"
|
#include "Leaderboard/LeaderboardJsonDumperIW4.h"
|
||||||
#include "LightDef/LightDefDumperIW4.h"
|
#include "LightDef/LightDefDumperIW4.h"
|
||||||
#include "Localize/LocalizeDumperIW4.h"
|
#include "Localize/LocalizeDumperIW4.h"
|
||||||
#include "Maps/AddonMapEntsDumperIW4.h"
|
#include "Maps/AddonMapEntsDumperIW4.h"
|
||||||
#include "Material/DumperMaterialIW4.h"
|
#include "Material/MaterialDecompilingDumperIW4.h"
|
||||||
#include "Menu/AssetDumperMenuDef.h"
|
#include "Menu/AssetDumperMenuDef.h"
|
||||||
#include "Menu/AssetDumperMenuList.h"
|
#include "Menu/AssetDumperMenuList.h"
|
||||||
#include "ObjWriting.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(AssetDumperPhysCollmap, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP)
|
||||||
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
|
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
|
||||||
DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL)
|
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(AssetDumperPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER)
|
||||||
DUMP_ASSET_POOL(AssetDumperVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER)
|
DUMP_ASSET_POOL(AssetDumperVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER)
|
||||||
DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
|
DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
|
||||||
|
@@ -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<Material>* pool)
|
|
||||||
{
|
|
||||||
auto* materialConstantState = context.GetZoneAssetDumperState<MaterialConstantZoneState>();
|
|
||||||
materialConstantState->ExtractNamesFromZone();
|
|
||||||
|
|
||||||
AbstractAssetDumper::DumpPool(context, pool);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AssetDumperMaterial::ShouldDump(XAssetInfo<Material>* asset)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset)
|
|
||||||
{
|
|
||||||
const auto assetFile = context.OpenAssetFile(material::GetFileNameForAssetName(asset->m_name));
|
|
||||||
|
|
||||||
if (!assetFile)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const auto* material = asset->Asset();
|
|
||||||
DumpMaterialAsJson(*assetFile, *material, context);
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Dumping/AbstractAssetDumper.h"
|
|
||||||
#include "Game/IW5/IW5.h"
|
|
||||||
|
|
||||||
namespace IW5
|
|
||||||
{
|
|
||||||
class AssetDumperMaterial final : public AbstractAssetDumper<Material>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void DumpPool(AssetDumpingContext& context, AssetPool<Material>* pool) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool ShouldDump(XAssetInfo<Material>* asset) override;
|
|
||||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset) override;
|
|
||||||
};
|
|
||||||
} // namespace IW5
|
|
@@ -1,12 +1,12 @@
|
|||||||
#include "ObjWriterIW5.h"
|
#include "ObjWriterIW5.h"
|
||||||
|
|
||||||
#include "Game/IW5/GameAssetPoolIW5.h"
|
#include "Game/IW5/GameAssetPoolIW5.h"
|
||||||
|
#include "Game/IW5/Material/MaterialJsonDumperIW5.h"
|
||||||
#include "Game/IW5/XModel/XModelDumperIW5.h"
|
#include "Game/IW5/XModel/XModelDumperIW5.h"
|
||||||
#include "Image/ImageDumperIW5.h"
|
#include "Image/ImageDumperIW5.h"
|
||||||
#include "Leaderboard/LeaderboardJsonDumperIW5.h"
|
#include "Leaderboard/LeaderboardJsonDumperIW5.h"
|
||||||
#include "Localize/LocalizeDumperIW5.h"
|
#include "Localize/LocalizeDumperIW5.h"
|
||||||
#include "Maps/AddonMapEntsDumperIW5.h"
|
#include "Maps/AddonMapEntsDumperIW5.h"
|
||||||
#include "Material/DumperMaterialIW5.h"
|
|
||||||
#include "Menu/AssetDumperMenuDef.h"
|
#include "Menu/AssetDumperMenuDef.h"
|
||||||
#include "Menu/AssetDumperMenuList.h"
|
#include "Menu/AssetDumperMenuList.h"
|
||||||
#include "ObjWriting.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(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
|
||||||
// DUMP_ASSET_POOL(AssetDumperXModelSurfs, m_xmodel_surfs, ASSET_TYPE_XMODEL_SURFS)
|
// DUMP_ASSET_POOL(AssetDumperXModelSurfs, m_xmodel_surfs, ASSET_TYPE_XMODEL_SURFS)
|
||||||
DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL)
|
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(AssetDumperMaterialPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER)
|
||||||
// DUMP_ASSET_POOL(AssetDumperMaterialVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER)
|
// DUMP_ASSET_POOL(AssetDumperMaterialVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER)
|
||||||
// DUMP_ASSET_POOL(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl, ASSET_TYPE_VERTEXDECL)
|
// DUMP_ASSET_POOL(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl, ASSET_TYPE_VERTEXDECL)
|
||||||
|
@@ -1,35 +0,0 @@
|
|||||||
#include "DumperMaterialT5.h"
|
|
||||||
|
|
||||||
#include "Game/T5/Material/JsonMaterialWriterT5.h"
|
|
||||||
#include "Game/T5/Material/MaterialConstantZoneStateT5.h"
|
|
||||||
#include "Material/MaterialCommon.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
using namespace T5;
|
|
||||||
|
|
||||||
void AssetDumperMaterial::DumpPool(AssetDumpingContext& context, AssetPool<Material>* pool)
|
|
||||||
{
|
|
||||||
auto* materialConstantState = context.GetZoneAssetDumperState<MaterialConstantZoneState>();
|
|
||||||
materialConstantState->ExtractNamesFromZone();
|
|
||||||
|
|
||||||
AbstractAssetDumper::DumpPool(context, pool);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AssetDumperMaterial::ShouldDump(XAssetInfo<Material>* asset)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* 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);
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Dumping/AbstractAssetDumper.h"
|
|
||||||
#include "Game/T5/T5.h"
|
|
||||||
|
|
||||||
namespace T5
|
|
||||||
{
|
|
||||||
class AssetDumperMaterial final : public AbstractAssetDumper<Material>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void DumpPool(AssetDumpingContext& context, AssetPool<Material>* pool) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool ShouldDump(XAssetInfo<Material>* asset) override;
|
|
||||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset) override;
|
|
||||||
};
|
|
||||||
} // namespace T5
|
|
@@ -1,10 +1,10 @@
|
|||||||
#include "ObjWriterT5.h"
|
#include "ObjWriterT5.h"
|
||||||
|
|
||||||
#include "Game/T5/GameAssetPoolT5.h"
|
#include "Game/T5/GameAssetPoolT5.h"
|
||||||
|
#include "Game/T5/Material/MaterialJsonDumperT5.h"
|
||||||
#include "Game/T5/XModel/XModelDumperT5.h"
|
#include "Game/T5/XModel/XModelDumperT5.h"
|
||||||
#include "Image/ImageDumperT5.h"
|
#include "Image/ImageDumperT5.h"
|
||||||
#include "Localize/LocalizeDumperT5.h"
|
#include "Localize/LocalizeDumperT5.h"
|
||||||
#include "Material/DumperMaterialT5.h"
|
|
||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
#include "PhysConstraints/AssetDumperPhysConstraints.h"
|
#include "PhysConstraints/AssetDumperPhysConstraints.h"
|
||||||
#include "PhysPreset/AssetDumperPhysPreset.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(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF)
|
||||||
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
|
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
|
||||||
DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL)
|
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(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
|
||||||
DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE)
|
DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE)
|
||||||
// DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND)
|
// DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND)
|
||||||
|
@@ -1,36 +0,0 @@
|
|||||||
#include "DumperMaterialT6.h"
|
|
||||||
|
|
||||||
#include "Game/T6/Material/JsonMaterialWriterT6.h"
|
|
||||||
#include "Game/T6/Material/MaterialConstantZoneStateT6.h"
|
|
||||||
#include "Material/MaterialCommon.h"
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
using namespace T6;
|
|
||||||
|
|
||||||
void AssetDumperMaterial::DumpPool(AssetDumpingContext& context, AssetPool<Material>* pool)
|
|
||||||
{
|
|
||||||
auto* materialConstantState = context.GetZoneAssetDumperState<MaterialConstantZoneState>();
|
|
||||||
materialConstantState->ExtractNamesFromZone();
|
|
||||||
|
|
||||||
AbstractAssetDumper::DumpPool(context, pool);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AssetDumperMaterial::ShouldDump(XAssetInfo<Material>* asset)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* 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);
|
|
||||||
}
|
|
@@ -1,17 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Dumping/AbstractAssetDumper.h"
|
|
||||||
#include "Game/T6/T6.h"
|
|
||||||
|
|
||||||
namespace T6
|
|
||||||
{
|
|
||||||
class AssetDumperMaterial final : public AbstractAssetDumper<Material>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void DumpPool(AssetDumpingContext& context, AssetPool<Material>* pool) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool ShouldDump(XAssetInfo<Material>* asset) override;
|
|
||||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset) override;
|
|
||||||
};
|
|
||||||
} // namespace T6
|
|
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
#include "FontIcon/FontIconDumperT6.h"
|
#include "FontIcon/FontIconDumperT6.h"
|
||||||
#include "Game/T6/GameAssetPoolT6.h"
|
#include "Game/T6/GameAssetPoolT6.h"
|
||||||
|
#include "Game/T6/Material/MaterialJsonDumperT6.h"
|
||||||
#include "Game/T6/XModel/XModelDumperT6.h"
|
#include "Game/T6/XModel/XModelDumperT6.h"
|
||||||
#include "Image/ImageDumperT6.h"
|
#include "Image/ImageDumperT6.h"
|
||||||
#include "Leaderboard/LeaderboardJsonDumperT6.h"
|
#include "Leaderboard/LeaderboardJsonDumperT6.h"
|
||||||
#include "Localize/LocalizeDumperT6.h"
|
#include "Localize/LocalizeDumperT6.h"
|
||||||
#include "Maps/MapEntsDumperT6.h"
|
#include "Maps/MapEntsDumperT6.h"
|
||||||
#include "Material/DumperMaterialT6.h"
|
|
||||||
#include "ObjWriting.h"
|
#include "ObjWriting.h"
|
||||||
#include "PhysConstraints/AssetDumperPhysConstraints.h"
|
#include "PhysConstraints/AssetDumperPhysConstraints.h"
|
||||||
#include "PhysPreset/AssetDumperPhysPreset.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(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF)
|
||||||
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
|
// DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS)
|
||||||
DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL)
|
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(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
|
||||||
DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE)
|
DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE)
|
||||||
DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND)
|
DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND)
|
||||||
|
@@ -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 <ostream>
|
|
||||||
|
|
||||||
namespace GAME
|
|
||||||
{
|
|
||||||
void DumpMaterialAsJson(std::ostream& stream, const Material& material, AssetDumpingContext& context);
|
|
||||||
} // namespace GAME
|
|
@@ -1,6 +1,6 @@
|
|||||||
#options GAME (IW3, IW4, IW5, T5, T6)
|
#options GAME (IW3, IW4, IW5, T5, T6)
|
||||||
|
|
||||||
#filename "Game/" + GAME + "/Material/JsonMaterialWriter" + GAME + ".cpp"
|
#filename "Game/" + GAME + "/Material/MaterialJsonDumper" + GAME + ".cpp"
|
||||||
|
|
||||||
#if GAME == "IW3"
|
#if GAME == "IW3"
|
||||||
#define FEATURE_IW3
|
#define FEATURE_IW3
|
||||||
@@ -24,16 +24,17 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This file was templated.
|
// This file was templated.
|
||||||
// See JsonMaterialWriter.cpp.template.
|
// See MaterialJsonDumper.cpp.template.
|
||||||
// Do not modify, changes will be lost.
|
// Do not modify, changes will be lost.
|
||||||
|
|
||||||
#set WRITER_HEADER "\"JsonMaterialWriter" + GAME + ".h\""
|
#set WRITER_HEADER "\"MaterialJsonDumper" + GAME + ".h\""
|
||||||
#include WRITER_HEADER
|
#include WRITER_HEADER
|
||||||
|
|
||||||
#ifdef HAS_WATER
|
#ifdef HAS_WATER
|
||||||
#include "Base64.h"
|
#include "Base64.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "Material/MaterialCommon.h"
|
||||||
#set COMMON_HEADER "\"Game/" + GAME + "/Common" + GAME + ".h\""
|
#set COMMON_HEADER "\"Game/" + GAME + "/Common" + GAME + ".h\""
|
||||||
#include COMMON_HEADER
|
#include COMMON_HEADER
|
||||||
#set JSON_HEADER "\"Game/" + GAME + "/Material/JsonMaterial" + GAME + ".h\""
|
#set JSON_HEADER "\"Game/" + GAME + "/Material/JsonMaterial" + GAME + ".h\""
|
||||||
@@ -41,18 +42,20 @@
|
|||||||
#set CONSTANTS_HEADER "\"Game/" + GAME + "/Material/MaterialConstantZoneState" + GAME + ".h\""
|
#set CONSTANTS_HEADER "\"Game/" + GAME + "/Material/MaterialConstantZoneState" + GAME + ".h\""
|
||||||
#include CONSTANTS_HEADER
|
#include CONSTANTS_HEADER
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
using namespace nlohmann;
|
using namespace nlohmann;
|
||||||
using namespace GAME;
|
using namespace GAME;
|
||||||
|
using namespace ::material;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
class JsonDumper
|
class JsonDumperImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
JsonDumper(AssetDumpingContext& context, std::ostream& stream)
|
JsonDumperImpl(AssetDumpingContext& context, std::ostream& stream)
|
||||||
: m_stream(stream),
|
: m_stream(stream),
|
||||||
m_material_constants(*context.GetZoneAssetDumperState<MaterialConstantZoneState>())
|
m_material_constants(*context.GetZoneAssetDumperState<MaterialConstantZoneState>())
|
||||||
{
|
{
|
||||||
@@ -355,11 +358,40 @@ namespace
|
|||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace GAME
|
namespace GAME::material
|
||||||
{
|
{
|
||||||
void DumpMaterialAsJson(std::ostream& stream, const Material& material, AssetDumpingContext& context)
|
void JsonDumper::DumpPool(AssetDumpingContext& context, AssetPool<Material>* pool)
|
||||||
{
|
{
|
||||||
const JsonDumper dumper(context, stream);
|
auto* materialConstantState = context.GetZoneAssetDumperState<MaterialConstantZoneState>();
|
||||||
dumper.Dump(material);
|
materialConstantState->ExtractNamesFromZone();
|
||||||
|
|
||||||
|
AbstractAssetDumper::DumpPool(context, pool);
|
||||||
}
|
}
|
||||||
} // namespace GAME
|
|
||||||
|
bool JsonDumper::ShouldDump(XAssetInfo<Material>* asset)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* 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
|
||||||
|
|
27
src/ObjWriting/Material/MaterialJsonDumper.h.template
Normal file
27
src/ObjWriting/Material/MaterialJsonDumper.h.template
Normal file
@@ -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<Material>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void DumpPool(AssetDumpingContext& context, AssetPool<Material>* pool) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
[[nodiscard]] bool ShouldDump(XAssetInfo<Material>* asset) override;
|
||||||
|
void DumpAsset(AssetDumpingContext& context, XAssetInfo<Material>* asset) override;
|
||||||
|
};
|
||||||
|
} // namespace GAME::material
|
@@ -3,6 +3,7 @@ ObjWritingTests = {}
|
|||||||
function ObjWritingTests:include(includes)
|
function ObjWritingTests:include(includes)
|
||||||
if includes:handle(self:name()) then
|
if includes:handle(self:name()) then
|
||||||
includedirs {
|
includedirs {
|
||||||
|
"%{wks.location}/src/ObjWriting",
|
||||||
path.join(TestFolder(), "ObjWritingTests")
|
path.join(TestFolder(), "ObjWritingTests")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#include "Game/IW3/Material/DumperMaterialIW3.h"
|
#include "Game/IW3/Material/MaterialJsonDumperIW3.h"
|
||||||
|
|
||||||
#include "Asset/AssetRegistration.h"
|
#include "Asset/AssetRegistration.h"
|
||||||
#include "Game/IW3/CommonIW3.h"
|
#include "Game/IW3/CommonIW3.h"
|
||||||
@@ -562,7 +562,7 @@ namespace
|
|||||||
|
|
||||||
GivenMaterial("wc/ch_plasterwall_long", materialPool, memory);
|
GivenMaterial("wc/ch_plasterwall_long", materialPool, memory);
|
||||||
|
|
||||||
AssetDumperMaterial dumper;
|
material::JsonDumper dumper;
|
||||||
dumper.DumpPool(context, &materialPool);
|
dumper.DumpPool(context, &materialPool);
|
||||||
|
|
||||||
const auto* file = mockOutput.GetMockedFile("materials/wc/ch_plasterwall_long.json");
|
const auto* file = mockOutput.GetMockedFile("materials/wc/ch_plasterwall_long.json");
|
@@ -1,4 +1,4 @@
|
|||||||
#include "Game/IW4/Material/DumperMaterialIW4.h"
|
#include "Game/IW4/Material/MaterialJsonDumperIW4.h"
|
||||||
|
|
||||||
#include "Asset/AssetRegistration.h"
|
#include "Asset/AssetRegistration.h"
|
||||||
#include "Game/IW4/CommonIW4.h"
|
#include "Game/IW4/CommonIW4.h"
|
||||||
@@ -543,7 +543,7 @@ namespace
|
|||||||
|
|
||||||
GivenMaterial("mc/ch_rubble01", materialPool, memory);
|
GivenMaterial("mc/ch_rubble01", materialPool, memory);
|
||||||
|
|
||||||
AssetDumperMaterial dumper;
|
material::JsonDumper dumper;
|
||||||
dumper.DumpPool(context, &materialPool);
|
dumper.DumpPool(context, &materialPool);
|
||||||
|
|
||||||
const auto* file = mockOutput.GetMockedFile("materials/mc/ch_rubble01.json");
|
const auto* file = mockOutput.GetMockedFile("materials/mc/ch_rubble01.json");
|
@@ -1,4 +1,4 @@
|
|||||||
#include "Game/IW5/Material/DumperMaterialIW5.h"
|
#include "Game/IW5/Material/MaterialJsonDumperIW5.h"
|
||||||
|
|
||||||
#include "Asset/AssetRegistration.h"
|
#include "Asset/AssetRegistration.h"
|
||||||
#include "Game/IW5/CommonIW5.h"
|
#include "Game/IW5/CommonIW5.h"
|
||||||
@@ -596,7 +596,7 @@ namespace
|
|||||||
|
|
||||||
GivenMaterial("wc/me_metal_rust_02", materialPool, memory);
|
GivenMaterial("wc/me_metal_rust_02", materialPool, memory);
|
||||||
|
|
||||||
AssetDumperMaterial dumper;
|
material::JsonDumper dumper;
|
||||||
dumper.DumpPool(context, &materialPool);
|
dumper.DumpPool(context, &materialPool);
|
||||||
|
|
||||||
const auto* file = mockOutput.GetMockedFile("materials/wc/me_metal_rust_02.json");
|
const auto* file = mockOutput.GetMockedFile("materials/wc/me_metal_rust_02.json");
|
@@ -1,4 +1,4 @@
|
|||||||
#include "Game/T5/Material/DumperMaterialT5.h"
|
#include "Game/T5/Material/MaterialJsonDumperT5.h"
|
||||||
|
|
||||||
#include "Asset/AssetRegistration.h"
|
#include "Asset/AssetRegistration.h"
|
||||||
#include "Game/T5/CommonT5.h"
|
#include "Game/T5/CommonT5.h"
|
||||||
@@ -625,7 +625,7 @@ namespace
|
|||||||
|
|
||||||
GivenMaterial("mc/ch_rubble01", materialPool, memory);
|
GivenMaterial("mc/ch_rubble01", materialPool, memory);
|
||||||
|
|
||||||
AssetDumperMaterial dumper;
|
material::JsonDumper dumper;
|
||||||
dumper.DumpPool(context, &materialPool);
|
dumper.DumpPool(context, &materialPool);
|
||||||
|
|
||||||
const auto* file = mockOutput.GetMockedFile("materials/mc/ch_rubble01.json");
|
const auto* file = mockOutput.GetMockedFile("materials/mc/ch_rubble01.json");
|
@@ -1,4 +1,4 @@
|
|||||||
#include "Game/T6/Material/DumperMaterialT6.h"
|
#include "Game/T6/Material/MaterialJsonDumperT6.h"
|
||||||
|
|
||||||
#include "Asset/AssetRegistration.h"
|
#include "Asset/AssetRegistration.h"
|
||||||
#include "Game/T6/CommonT6.h"
|
#include "Game/T6/CommonT6.h"
|
||||||
@@ -472,7 +472,7 @@ namespace
|
|||||||
AssetPoolDynamic<Material> materialPool(0);
|
AssetPoolDynamic<Material> materialPool(0);
|
||||||
GivenMaterial("wpc/metal_ac_duct", materialPool, memory);
|
GivenMaterial("wpc/metal_ac_duct", materialPool, memory);
|
||||||
|
|
||||||
AssetDumperMaterial dumper;
|
material::JsonDumper dumper;
|
||||||
dumper.DumpPool(context, &materialPool);
|
dumper.DumpPool(context, &materialPool);
|
||||||
|
|
||||||
const auto* file = mockOutput.GetMockedFile("materials/wpc/metal_ac_duct.json");
|
const auto* file = mockOutput.GetMockedFile("materials/wpc/metal_ac_duct.json");
|
Reference in New Issue
Block a user