Add basis for iw4 techset dumping

This commit is contained in:
Jan
2022-03-23 13:45:01 +01:00
parent 9009543c58
commit 66b62611f3
10 changed files with 258 additions and 4 deletions

View File

@ -0,0 +1,12 @@
#include "AssetDumperPixelShader.h"
using namespace IW4;
bool AssetDumperPixelShader::ShouldDump(XAssetInfo<MaterialPixelShader>* asset)
{
return true;
}
void AssetDumperPixelShader::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialPixelShader>* asset)
{
}

View File

@ -0,0 +1,14 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
namespace IW4
{
class AssetDumperPixelShader final : public AbstractAssetDumper<MaterialPixelShader>
{
protected:
bool ShouldDump(XAssetInfo<MaterialPixelShader>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialPixelShader>* asset) override;
};
}

View File

@ -0,0 +1,99 @@
#include "AssetDumperTechniqueSet.h"
#include <sstream>
#include "Dumping/AbstractTextDumper.h"
using namespace IW4;
namespace IW4
{
class TechniqueDumpingZoneState final : public IZoneAssetDumperState
{
std::set<const MaterialTechnique*> m_dumped_techniques;
public:
bool ShouldDumpTechnique(const MaterialTechnique* technique)
{
if (m_dumped_techniques.find(technique) != m_dumped_techniques.end())
return false;
m_dumped_techniques.emplace(technique);
return true;
}
};
class TechniqueFileWriter : public AbstractTextDumper
{
public:
explicit TechniqueFileWriter(std::ostream& stream)
: AbstractTextDumper(stream)
{
}
void DumpTechnique(const MaterialTechnique* technique)
{
m_stream << "technique lol";
}
};
class TechsetFileWriter : public AbstractTextDumper
{
public:
explicit TechsetFileWriter(std::ostream& stream)
: AbstractTextDumper(stream)
{
}
void DumpTechset(const MaterialTechniqueSet* techset)
{
m_stream << "techset lol";
}
};
}
std::string AssetDumperTechniqueSet::GetTechniqueFileName(const MaterialTechnique* technique)
{
std::ostringstream ss;
ss << "techniques/" << technique->name << ".tech";
return ss.str();
}
std::string AssetDumperTechniqueSet::GetTechsetFileName(const MaterialTechniqueSet* techset)
{
std::ostringstream ss;
ss << "techsets/" << techset->name << ".techset";
return ss.str();
}
bool AssetDumperTechniqueSet::ShouldDump(XAssetInfo<MaterialTechniqueSet>* asset)
{
return true;
}
void AssetDumperTechniqueSet::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialTechniqueSet>* asset)
{
const auto* techset = asset->Asset();
const auto techsetFile = context.OpenAssetFile(GetTechsetFileName(techset));
if (techsetFile)
{
TechsetFileWriter writer(*techsetFile);
writer.DumpTechset(techset);
}
auto* techniqueState = context.GetZoneAssetDumperState<TechniqueDumpingZoneState>();
for (const auto* technique : techset->techniques)
{
if (technique && techniqueState->ShouldDumpTechnique(technique))
{
const auto techniqueFile = context.OpenAssetFile(GetTechniqueFileName(technique));
if (techniqueFile)
{
TechniqueFileWriter writer(*techniqueFile);
writer.DumpTechnique(technique);
}
}
}
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
namespace IW4
{
class AssetDumperTechniqueSet final : public AbstractAssetDumper<MaterialTechniqueSet>
{
static std::string GetTechniqueFileName(const MaterialTechnique* technique);
static std::string GetTechsetFileName(const MaterialTechniqueSet* techset);
protected:
bool ShouldDump(XAssetInfo<MaterialTechniqueSet>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialTechniqueSet>* asset) override;
};
}

View File

@ -0,0 +1,12 @@
#include "AssetDumperVertexDecl.h"
using namespace IW4;
bool AssetDumperVertexDecl::ShouldDump(XAssetInfo<MaterialVertexDeclaration>* asset)
{
return true;
}
void AssetDumperVertexDecl::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialVertexDeclaration>* asset)
{
}

View File

@ -0,0 +1,14 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
namespace IW4
{
class AssetDumperVertexDecl final : public AbstractAssetDumper<MaterialVertexDeclaration>
{
protected:
bool ShouldDump(XAssetInfo<MaterialVertexDeclaration>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialVertexDeclaration>* asset) override;
};
}

View File

@ -0,0 +1,12 @@
#include "AssetDumperVertexShader.h"
using namespace IW4;
bool AssetDumperVertexShader::ShouldDump(XAssetInfo<MaterialVertexShader>* asset)
{
return true;
}
void AssetDumperVertexShader::DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialVertexShader>* asset)
{
}

View File

@ -0,0 +1,14 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/IW4/IW4.h"
namespace IW4
{
class AssetDumperVertexShader final : public AbstractAssetDumper<MaterialVertexShader>
{
protected:
bool ShouldDump(XAssetInfo<MaterialVertexShader>* asset) override;
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MaterialVertexShader>* asset) override;
};
}

View File

@ -13,12 +13,16 @@
#include "AssetDumpers/AssetDumperMenuList.h"
#include "AssetDumpers/AssetDumperPhysCollmap.h"
#include "AssetDumpers/AssetDumperPhysPreset.h"
#include "AssetDumpers/AssetDumperPixelShader.h"
#include "AssetDumpers/AssetDumperRawFile.h"
#include "AssetDumpers/AssetDumperSndCurve.h"
#include "AssetDumpers/AssetDumperStringTable.h"
#include "AssetDumpers/AssetDumperStructuredDataDefSet.h"
#include "AssetDumpers/AssetDumperTechniqueSet.h"
#include "AssetDumpers/AssetDumperTracer.h"
#include "AssetDumpers/AssetDumperVehicle.h"
#include "AssetDumpers/AssetDumperVertexDecl.h"
#include "AssetDumpers/AssetDumperVertexShader.h"
#include "AssetDumpers/AssetDumperWeapon.h"
#include "AssetDumpers/AssetDumperXModel.h"
@ -45,10 +49,10 @@ bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
// 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(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)
// DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
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(AssetDumperVertexDecl, m_material_vertex_decl, ASSET_TYPE_VERTEXDECL)
DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET)
DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE)
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE)