mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-05 08:17:25 +00:00
Add dumper and reader for IW4 GfxLightDef
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#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);
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperGfxLightDef 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;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user