mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-01 22:47:26 +00:00
refactor: restructure light def dumper
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
#include "AssetDumperGfxLightDef.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
std::string AssetDumperGfxLightDef::GetAssetFilename(const std::string& assetName)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
|
||||
ss << "lights/" << assetName;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool AssetDumperGfxLightDef::ShouldDump(XAssetInfo<GfxLightDef>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssetDumperGfxLightDef::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxLightDef>* asset)
|
||||
{
|
||||
const auto* lightDef = asset->Asset();
|
||||
const auto assetFile = context.OpenAssetFile(GetAssetFilename(asset->m_name));
|
||||
|
||||
if (!assetFile || lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||
return;
|
||||
|
||||
auto& stream = *assetFile;
|
||||
|
||||
const auto* imageName = lightDef->attenuation.image->name;
|
||||
if (imageName[0] == ',')
|
||||
imageName = &imageName[1];
|
||||
|
||||
stream << lightDef->attenuation.samplerState << imageName << static_cast<char>(lightDef->lmapLookupStart);
|
||||
}
|
33
src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.cpp
Normal file
33
src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "LightDefDumperIW4.h"
|
||||
|
||||
#include "LightDef/LightDefCommon.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace IW4;
|
||||
using namespace ::light_def;
|
||||
|
||||
namespace IW4::light_def
|
||||
{
|
||||
bool Dumper::ShouldDump(XAssetInfo<GfxLightDef>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxLightDef>* asset)
|
||||
{
|
||||
const auto* lightDef = asset->Asset();
|
||||
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name));
|
||||
|
||||
if (!assetFile || lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||
return;
|
||||
|
||||
auto& stream = *assetFile;
|
||||
|
||||
const auto* imageName = lightDef->attenuation.image->name;
|
||||
if (imageName[0] == ',')
|
||||
imageName = &imageName[1];
|
||||
|
||||
stream << lightDef->attenuation.samplerState << imageName << static_cast<char>(lightDef->lmapLookupStart);
|
||||
}
|
||||
} // namespace IW4::light_def
|
@@ -3,12 +3,10 @@
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
namespace IW4::light_def
|
||||
{
|
||||
class AssetDumperGfxLightDef final : public AbstractAssetDumper<GfxLightDef>
|
||||
class Dumper final : public AbstractAssetDumper<GfxLightDef>
|
||||
{
|
||||
static std::string GetAssetFilename(const std::string& assetName);
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<GfxLightDef>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<GfxLightDef>* asset) override;
|
@@ -4,7 +4,7 @@
|
||||
#include "Game/IW4/XModel/XModelDumperIW4.h"
|
||||
#include "Image/AssetDumperGfxImage.h"
|
||||
#include "Leaderboard/LeaderboardJsonDumperIW4.h"
|
||||
#include "LightDef/AssetDumperGfxLightDef.h"
|
||||
#include "LightDef/LightDefDumperIW4.h"
|
||||
#include "Localize/AssetDumperLocalizeEntry.h"
|
||||
#include "Maps/AssetDumperAddonMapEnts.h"
|
||||
#include "Material/DumperMaterialIW4.h"
|
||||
@@ -57,7 +57,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
// DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS)
|
||||
// DUMP_ASSET_POOL(AssetDumperFxWorld, m_fx_world, ASSET_TYPE_FXWORLD)
|
||||
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD)
|
||||
DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
|
||||
DUMP_ASSET_POOL(light_def::Dumper, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
|
||||
// DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT)
|
||||
DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST)
|
||||
DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU)
|
||||
|
Reference in New Issue
Block a user