mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-19 03:07:58 -05:00
Dump iw4 sound curves
This commit is contained in:
44
src/ObjWriting/Dumping/SndCurve/SndCurveDumper.cpp
Normal file
44
src/ObjWriting/Dumping/SndCurve/SndCurveDumper.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include "SndCurveDumper.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <iomanip>
|
||||
|
||||
SndCurveDumper::SndCurveDumper(std::ostream& stream)
|
||||
: SndCurveDumper(stream, DEFAULT_PRECISION)
|
||||
{
|
||||
}
|
||||
|
||||
SndCurveDumper::SndCurveDumper(std::ostream& stream, const size_t precision)
|
||||
: m_stream(stream),
|
||||
m_precision(precision),
|
||||
m_current_knot(0u),
|
||||
m_total_knots(0u)
|
||||
{
|
||||
}
|
||||
|
||||
void SndCurveDumper::Init(const size_t totalKnots)
|
||||
{
|
||||
m_total_knots = totalKnots;
|
||||
m_current_knot = 0;
|
||||
|
||||
m_stream << "SNDCURVE\n\n";
|
||||
m_stream << totalKnots;
|
||||
}
|
||||
|
||||
void SndCurveDumper::WriteKnot(const float x, const float y)
|
||||
{
|
||||
assert(m_current_knot >= m_total_knots);
|
||||
|
||||
m_stream << "\n" << std::fixed << std::setprecision(m_precision) << x << " " << y;
|
||||
|
||||
m_current_knot++;
|
||||
}
|
||||
|
||||
void SndCurveDumper::WriteKnot(const double x, const double y)
|
||||
{
|
||||
assert(m_current_knot >= m_total_knots);
|
||||
|
||||
m_stream << x << " " << y << "\n";
|
||||
|
||||
m_current_knot++;
|
||||
}
|
20
src/ObjWriting/Dumping/SndCurve/SndCurveDumper.h
Normal file
20
src/ObjWriting/Dumping/SndCurve/SndCurveDumper.h
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include <ostream>
|
||||
|
||||
class SndCurveDumper
|
||||
{
|
||||
static constexpr auto DEFAULT_PRECISION = 4;
|
||||
|
||||
std::ostream& m_stream;
|
||||
size_t m_precision;
|
||||
size_t m_current_knot;
|
||||
size_t m_total_knots;
|
||||
|
||||
public:
|
||||
explicit SndCurveDumper(std::ostream& stream);
|
||||
SndCurveDumper(std::ostream& stream, size_t precision);
|
||||
|
||||
void Init(size_t totalKnots);
|
||||
void WriteKnot(float x, float y);
|
||||
void WriteKnot(double x, double y);
|
||||
};
|
Reference in New Issue
Block a user