2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2015-09-09 00:49:20 +00:00
|
|
|
|
2018-06-29 20:21:36 +00:00
|
|
|
#include "DataSpec/DNACommon/DNACommon.hpp"
|
2015-09-09 00:49:20 +00:00
|
|
|
#include "CMDLMaterials.hpp"
|
|
|
|
#include "CSKR.hpp"
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace DataSpec::DNAMP2 {
|
2015-09-09 00:49:20 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct MREA {
|
|
|
|
class StreamReader : public athena::io::IStreamReader {
|
|
|
|
protected:
|
|
|
|
struct BlockInfo : BigDNA {
|
|
|
|
AT_DECL_DNA
|
|
|
|
Value<atUint32> bufSize;
|
|
|
|
Value<atUint32> decompSize;
|
|
|
|
Value<atUint32> compSize;
|
|
|
|
Value<atUint32> secCount;
|
|
|
|
};
|
|
|
|
std::vector<BlockInfo> m_blockInfos;
|
2015-09-09 00:49:20 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
size_t m_compBufSz;
|
|
|
|
std::unique_ptr<atUint8[]> m_compBuf;
|
|
|
|
size_t m_decompBufSz;
|
|
|
|
std::unique_ptr<atUint8[]> m_decompBuf;
|
|
|
|
athena::io::IStreamReader& m_source;
|
|
|
|
atUint64 m_blkBase;
|
|
|
|
atUint32 m_blkCount;
|
|
|
|
atUint32 m_totalDecompLen = 0;
|
|
|
|
atUint32 m_pos = 0;
|
2015-09-09 00:49:20 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
atUint32 m_nextBlk = 0;
|
|
|
|
atUint32 m_posInBlk = 0;
|
|
|
|
atUint32 m_blkSz = 0;
|
|
|
|
void nextBlock();
|
2015-09-09 00:49:20 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
StreamReader(athena::io::IStreamReader& source)
|
|
|
|
: m_compBufSz(0x4120)
|
|
|
|
, m_compBuf(new atUint8[0x4120])
|
|
|
|
, m_decompBufSz(0x4120)
|
|
|
|
, m_decompBuf(new atUint8[0x4120])
|
|
|
|
, m_source(source) {} /* Empty constructor for inheriting */
|
2015-09-20 06:09:27 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
public:
|
|
|
|
StreamReader(athena::io::IStreamReader& source, atUint32 blkCount);
|
2019-08-10 02:32:48 +00:00
|
|
|
void seek(atInt64 diff, athena::SeekOrigin whence) override;
|
2020-04-09 05:19:50 +00:00
|
|
|
void seekToSection(atUint32 sec, const std::vector<atUint32>& secSizes);
|
2019-08-10 02:32:48 +00:00
|
|
|
atUint64 position() const override { return m_pos; }
|
|
|
|
atUint64 length() const override { return m_totalDecompLen; }
|
|
|
|
atUint64 readUBytesToBuf(void* buf, atUint64 len) override;
|
2018-12-08 05:30:43 +00:00
|
|
|
void writeDecompInfos(athena::io::IStreamWriter& writer) const;
|
|
|
|
};
|
2015-09-09 00:49:20 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct Header : BigDNA {
|
|
|
|
AT_DECL_DNA
|
|
|
|
Value<atUint32> magic;
|
|
|
|
Value<atUint32> version;
|
|
|
|
Value<atVec4f> localToWorldMtx[3];
|
|
|
|
Value<atUint32> meshCount;
|
|
|
|
Value<atUint32> sclyLayerCount;
|
|
|
|
Value<atUint32> secCount;
|
|
|
|
Value<atUint32> geomSecIdx;
|
|
|
|
Value<atUint32> sclySecIdx;
|
|
|
|
Value<atUint32> scgnSecIdx;
|
|
|
|
Value<atUint32> collisionSecIdx;
|
|
|
|
Value<atUint32> unkSecIdx;
|
|
|
|
Value<atUint32> lightSecIdx;
|
|
|
|
Value<atUint32> emptySecIdx;
|
|
|
|
Value<atUint32> pathSecIdx;
|
|
|
|
Value<atUint32> unk2SecIdx;
|
|
|
|
Value<atUint32> unk3SecIdx;
|
|
|
|
Value<atUint32> egmcSecIdx;
|
|
|
|
Value<atUint32> compressedBlockCount;
|
2019-09-08 01:01:16 +00:00
|
|
|
Seek<12, athena::SeekOrigin::Current> align1;
|
2018-12-08 05:30:43 +00:00
|
|
|
Vector<atUint32, AT_DNA_COUNT(secCount)> secSizes;
|
|
|
|
};
|
2015-09-09 00:49:20 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct MeshHeader : BigDNA {
|
|
|
|
AT_DECL_DNA
|
|
|
|
struct VisorFlags : BigDNA {
|
|
|
|
AT_DECL_DNA
|
|
|
|
Value<atUint32> flags;
|
|
|
|
enum class ThermalLevel { Cool, Hot, Warm };
|
|
|
|
static const char* GetThermalLevelStr(ThermalLevel t) {
|
|
|
|
switch (t) {
|
|
|
|
case ThermalLevel::Cool:
|
|
|
|
return "COOL";
|
|
|
|
case ThermalLevel::Hot:
|
|
|
|
return "HOT";
|
|
|
|
case ThermalLevel::Warm:
|
|
|
|
return "WARM";
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
bool disableEnviro() const { return flags >> 1 & 0x1; }
|
|
|
|
void setDisableEnviro(bool v) {
|
|
|
|
flags &= ~0x2;
|
|
|
|
flags |= v << 1;
|
|
|
|
}
|
|
|
|
bool disableThermal() const { return flags >> 2 & 0x1; }
|
|
|
|
void setDisableThermal(bool v) {
|
|
|
|
flags &= ~0x4;
|
|
|
|
flags |= v << 2;
|
|
|
|
}
|
|
|
|
bool disableXray() const { return flags >> 3 & 0x1; }
|
|
|
|
void setDisableXray(bool v) {
|
|
|
|
flags &= ~0x8;
|
|
|
|
flags |= v << 3;
|
|
|
|
}
|
|
|
|
ThermalLevel thermalLevel() const { return ThermalLevel(flags >> 4 & 0x3); }
|
|
|
|
void setThermalLevel(ThermalLevel v) {
|
|
|
|
flags &= ~0x30;
|
|
|
|
flags |= atUint32(v) << 4;
|
|
|
|
}
|
|
|
|
const char* thermalLevelStr() const { return GetThermalLevelStr(thermalLevel()); }
|
|
|
|
} visorFlags;
|
|
|
|
Value<atVec4f> xfMtx[3];
|
|
|
|
Value<atVec3f> aabb[2];
|
|
|
|
};
|
2015-09-09 00:49:20 +00:00
|
|
|
|
2020-03-18 06:12:43 +00:00
|
|
|
static UniqueID32 GetPATHId(PAKEntryReadStream& rs);
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath,
|
|
|
|
PAKRouter<PAKBridge>& pakRouter, const DNAMP2::PAK::Entry& entry, bool,
|
2021-06-30 18:20:45 +00:00
|
|
|
hecl::blender::Token& btok, std::function<void(const char*)>);
|
2015-09-09 00:49:20 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace DataSpec::DNAMP2
|