mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Dump IW4 tracers
This commit is contained in:
parent
5b68b21755
commit
c9a0392fc1
36
src/ObjCommon/Game/IW4/InfoString/TracerFields.h
Normal file
36
src/ObjCommon/Game/IW4/InfoString/TracerFields.h
Normal file
@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
inline cspField_t tracer_fields[]
|
||||
{
|
||||
{ "material", offsetof(TracerDef, material), CSPFT_MATERIAL },
|
||||
{ "drawInterval", offsetof(TracerDef, drawInterval), CSPFT_INT },
|
||||
{ "speed", offsetof(TracerDef, speed), CSPFT_FLOAT },
|
||||
{ "beamLength", offsetof(TracerDef, beamLength), CSPFT_FLOAT },
|
||||
{ "beamWidth", offsetof(TracerDef, beamWidth), CSPFT_FLOAT },
|
||||
{ "screwRadius", offsetof(TracerDef, screwRadius), CSPFT_FLOAT },
|
||||
{ "screwDist", offsetof(TracerDef, screwDist), CSPFT_FLOAT },
|
||||
{ "colorR0", offsetof(TracerDef, colors[0][0]), CSPFT_FLOAT},
|
||||
{ "colorG0", offsetof(TracerDef, colors[0][1]), CSPFT_FLOAT },
|
||||
{ "colorB0", offsetof(TracerDef, colors[0][2]), CSPFT_FLOAT },
|
||||
{ "colorA0", offsetof(TracerDef, colors[0][3]), CSPFT_FLOAT },
|
||||
{ "colorR1", offsetof(TracerDef, colors[1][0]), CSPFT_FLOAT },
|
||||
{ "colorG1", offsetof(TracerDef, colors[1][1]), CSPFT_FLOAT },
|
||||
{ "colorB1", offsetof(TracerDef, colors[1][2]), CSPFT_FLOAT },
|
||||
{ "colorA1", offsetof(TracerDef, colors[1][3]), CSPFT_FLOAT },
|
||||
{ "colorR2", offsetof(TracerDef, colors[2][0]), CSPFT_FLOAT },
|
||||
{ "colorG2", offsetof(TracerDef, colors[2][1]), CSPFT_FLOAT },
|
||||
{ "colorB2", offsetof(TracerDef, colors[2][2]), CSPFT_FLOAT },
|
||||
{ "colorA2", offsetof(TracerDef, colors[2][3]), CSPFT_FLOAT },
|
||||
{ "colorR3", offsetof(TracerDef, colors[3][0]), CSPFT_FLOAT },
|
||||
{ "colorG3", offsetof(TracerDef, colors[3][1]), CSPFT_FLOAT },
|
||||
{ "colorB3", offsetof(TracerDef, colors[3][2]), CSPFT_FLOAT },
|
||||
{ "colorA3", offsetof(TracerDef, colors[3][3]), CSPFT_FLOAT },
|
||||
{ "colorR4", offsetof(TracerDef, colors[4][0]), CSPFT_FLOAT },
|
||||
{ "colorG4", offsetof(TracerDef, colors[4][1]), CSPFT_FLOAT },
|
||||
{ "colorB4", offsetof(TracerDef, colors[4][2]), CSPFT_FLOAT },
|
||||
{ "colorA4", offsetof(TracerDef, colors[4][3]), CSPFT_FLOAT },
|
||||
};
|
||||
}
|
73
src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTracer.cpp
Normal file
73
src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTracer.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
#include "AssetDumperTracer.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
#include "Game/IW4/CommonIW4.h"
|
||||
#include "Game/IW4/ObjConstantsIW4.h"
|
||||
#include "Game/IW4/InfoString/InfoStringFromStructConverter.h"
|
||||
#include "Game/IW4/InfoString/TracerFields.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class InfoStringFromTracerConverter final : public InfoStringFromStructConverter
|
||||
{
|
||||
protected:
|
||||
void FillFromExtensionField(const cspField_t& field) override
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
public:
|
||||
InfoStringFromTracerConverter(const TracerDef* structure, const cspField_t* fields, const size_t fieldCount, std::function<std::string(scr_string_t)> scriptStringValueCallback)
|
||||
: InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback))
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
InfoString AssetDumperTracer::CreateInfoString(XAssetInfo<TracerDef>* asset)
|
||||
{
|
||||
InfoStringFromTracerConverter converter(asset->Asset(), tracer_fields, std::extent<decltype(tracer_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
|
||||
{
|
||||
assert(scrStr < asset->m_zone->m_script_strings.Count());
|
||||
if (scrStr >= asset->m_zone->m_script_strings.Count())
|
||||
return "";
|
||||
|
||||
return asset->m_zone->m_script_strings[scrStr];
|
||||
});
|
||||
|
||||
return converter.Convert();
|
||||
}
|
||||
|
||||
bool AssetDumperTracer::ShouldDump(XAssetInfo<TracerDef>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssetDumperTracer::DumpAsset(AssetDumpingContext& context, XAssetInfo<TracerDef>* asset)
|
||||
{
|
||||
// Only dump raw when no gdt available
|
||||
if (context.m_gdt)
|
||||
{
|
||||
const auto infoString = CreateInfoString(asset);
|
||||
GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_TRACER);
|
||||
infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_TRACER, gdtEntry);
|
||||
context.m_gdt->WriteEntry(gdtEntry);
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto assetFile = context.OpenAssetFile("tracer/" + asset->m_name);
|
||||
|
||||
if (!assetFile)
|
||||
return;
|
||||
|
||||
auto& stream = *assetFile;
|
||||
const auto infoString = CreateInfoString(asset);
|
||||
const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_TRACER);
|
||||
stream.write(stringValue.c_str(), stringValue.size());
|
||||
}
|
||||
}
|
17
src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTracer.h
Normal file
17
src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTracer.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperTracer final : public AbstractAssetDumper<TracerDef>
|
||||
{
|
||||
static InfoString CreateInfoString(XAssetInfo<TracerDef>* asset);
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<TracerDef>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<TracerDef>* asset) override;
|
||||
};
|
||||
}
|
@ -16,6 +16,7 @@
|
||||
#include "AssetDumpers/AssetDumperRawFile.h"
|
||||
#include "AssetDumpers/AssetDumperSndCurve.h"
|
||||
#include "AssetDumpers/AssetDumperStringTable.h"
|
||||
#include "AssetDumpers/AssetDumperTracer.h"
|
||||
#include "AssetDumpers/AssetDumperVehicle.h"
|
||||
#include "AssetDumpers/AssetDumperWeapon.h"
|
||||
#include "AssetDumpers/AssetDumperXModel.h"
|
||||
@ -71,7 +72,7 @@ bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
|
||||
DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE)
|
||||
// DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard, ASSET_TYPE_LEADERBOARD)
|
||||
// DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF)
|
||||
// DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer, ASSET_TYPE_TRACER)
|
||||
DUMP_ASSET_POOL(AssetDumperTracer, m_tracer, ASSET_TYPE_TRACER)
|
||||
DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle, ASSET_TYPE_VEHICLE)
|
||||
DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user