mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-05 00:07:25 +00:00
Dump iw4 sound curves
This commit is contained in:
39
src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperSndCurve.cpp
Normal file
39
src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperSndCurve.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "AssetDumperSndCurve.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "Dumping/SndCurve/SndCurveDumper.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
std::string AssetDumperSndCurve::GetAssetFilename(const std::string& assetName)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
|
||||
ss << "soundaliases/" << assetName << ".vfcurve";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool AssetDumperSndCurve::ShouldDump(XAssetInfo<SndCurve>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssetDumperSndCurve::DumpAsset(AssetDumpingContext& context, XAssetInfo<SndCurve>* asset)
|
||||
{
|
||||
const auto* sndCurve = asset->Asset();
|
||||
|
||||
const auto assetFile = context.OpenAssetFile(GetAssetFilename(sndCurve->filename));
|
||||
|
||||
if (!assetFile)
|
||||
return;
|
||||
|
||||
SndCurveDumper dumper(*assetFile);
|
||||
|
||||
const auto knotCount = std::min(static_cast<size_t>(sndCurve->knotCount), std::extent_v<decltype(SndCurve::knots)>);
|
||||
dumper.Init(knotCount);
|
||||
|
||||
for (auto i = 0u; i < knotCount; i++)
|
||||
dumper.WriteKnot(sndCurve->knots[i][0], sndCurve->knots[i][1]);
|
||||
}
|
16
src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperSndCurve.h
Normal file
16
src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperSndCurve.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetDumperSndCurve final : public AbstractAssetDumper<SndCurve>
|
||||
{
|
||||
static std::string GetAssetFilename(const std::string& assetName);
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<SndCurve>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<SndCurve>* asset) override;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user