mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 15:04:56 +00:00
Initial PATH support for MP2
This commit is contained in:
@@ -23,6 +23,7 @@ set(DNAMP2_SOURCES
|
||||
MREA.cpp
|
||||
MAPA.hpp
|
||||
MAPU.hpp
|
||||
PATH.hpp PATH.cpp
|
||||
AFSM.hpp
|
||||
STRG.hpp STRG.cpp)
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "MREA.hpp"
|
||||
#include "MAPA.hpp"
|
||||
#include "MAPU.hpp"
|
||||
#include "PATH.hpp"
|
||||
#include "AFSM.hpp"
|
||||
#include "SAVW.hpp"
|
||||
#include "AGSC.hpp"
|
||||
@@ -171,6 +172,18 @@ void PAKBridge::addCMDLRigPairs(PAKRouter<PAKBridge>& pakRouter, CharacterAssoci
|
||||
}
|
||||
}
|
||||
|
||||
void PAKBridge::addPATHToMREA(PAKRouter<PAKBridge>& pakRouter,
|
||||
std::unordered_map<UniqueID32, UniqueID32>& pathToMrea) const {
|
||||
for (const auto& [id, entry] : m_pak.m_entries) {
|
||||
if (entry.type == FOURCC('MREA')) {
|
||||
PAKEntryReadStream rs = entry.beginReadStream(m_node);
|
||||
UniqueID32 pathID = MREA::GetPATHId(rs);
|
||||
if (pathID.isValid())
|
||||
pathToMrea[pathID] = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const atVec4f BottomRow = {{0.f, 0.f, 0.f, 1.f}};
|
||||
|
||||
void PAKBridge::addMAPATransforms(PAKRouter<PAKBridge>& pakRouter,
|
||||
@@ -190,6 +203,18 @@ void PAKBridge::addMAPATransforms(PAKRouter<PAKBridge>& pakRouter,
|
||||
fmt::format(fmt(_SYS_STR("!name_{}.yaml")), mlvl.worldNameId));
|
||||
|
||||
for (const MLVL::Area& area : mlvl.areas) {
|
||||
#if 0
|
||||
{
|
||||
/* Get PATH transform */
|
||||
const nod::Node* areaNode;
|
||||
const PAK::Entry* areaEntry = pakRouter.lookupEntry(area.areaMREAId, &areaNode);
|
||||
PAKEntryReadStream rs = areaEntry->beginReadStream(*areaNode);
|
||||
UniqueID32 pathId = MREA::GetPATHId(rs);
|
||||
if (pathId.isValid())
|
||||
addTo[pathId] = zeus::CMatrix4f(area.transformMtx[0], area.transformMtx[1], area.transformMtx[2], BottomRow)
|
||||
.transposed();
|
||||
}
|
||||
#endif
|
||||
hecl::ProjectPath areaDirPath = pakRouter.getWorking(area.areaMREAId).getParentPath();
|
||||
if (area.areaNameId.isValid())
|
||||
pathOverrides[area.areaNameId] = hecl::ProjectPath(areaDirPath,
|
||||
@@ -247,6 +272,8 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const nod::Node& pakNode, con
|
||||
return {MAPA::Extract, {_SYS_STR(".blend")}, 4};
|
||||
case SBIG('MAPU'):
|
||||
return {MAPU::Extract, {_SYS_STR(".blend")}, 5};
|
||||
// case SBIG('PATH'):
|
||||
// return {PATH::Extract, {_SYS_STR(".blend")}, 5};
|
||||
case SBIG('FSM2'):
|
||||
return {DNAFSM2::ExtractFSM2<UniqueID32>, {_SYS_STR(".yaml")}};
|
||||
case SBIG('FONT'):
|
||||
|
||||
@@ -31,6 +31,9 @@ public:
|
||||
|
||||
void addCMDLRigPairs(PAKRouter<PAKBridge>& pakRouter, CharacterAssociations<UniqueID32>& charAssoc) const;
|
||||
|
||||
void addPATHToMREA(PAKRouter<PAKBridge>& pakRouter,
|
||||
std::unordered_map<UniqueID32, UniqueID32>& pathToMrea) const;
|
||||
|
||||
void addMAPATransforms(PAKRouter<PAKBridge>& pakRouter, std::unordered_map<UniqueID32, zeus::CMatrix4f>& addTo,
|
||||
std::unordered_map<UniqueID32, hecl::ProjectPath>& pathOverrides) const;
|
||||
};
|
||||
|
||||
@@ -296,5 +296,22 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
|
||||
return conn.saveBlend();
|
||||
}
|
||||
|
||||
UniqueID32 MREA::GetPATHId(PAKEntryReadStream& rs) {
|
||||
/* Do extract */
|
||||
Header head;
|
||||
head.read(rs);
|
||||
rs.seekAlign32();
|
||||
|
||||
/* Skip to PATH */
|
||||
atUint32 curSec = 0;
|
||||
atUint64 secStart = rs.position();
|
||||
while (curSec != head.pathSecIdx)
|
||||
secStart += head.secSizes[curSec++];
|
||||
if (!head.secSizes[curSec])
|
||||
return {};
|
||||
rs.seek(secStart, athena::SeekOrigin::Begin);
|
||||
return {rs};
|
||||
}
|
||||
|
||||
} // namespace DNAMP2
|
||||
} // namespace DataSpec
|
||||
|
||||
@@ -118,6 +118,8 @@ struct MREA {
|
||||
Value<atVec3f> aabb[2];
|
||||
};
|
||||
|
||||
static UniqueID32 GetPATHId(PAKEntryReadStream& rs);
|
||||
|
||||
static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath,
|
||||
PAKRouter<PAKBridge>& pakRouter, const DNAMP2::PAK::Entry& entry, bool,
|
||||
hecl::blender::Token& btok, std::function<void(const hecl::SystemChar*)>);
|
||||
|
||||
26
DataSpec/DNAMP2/PATH.cpp
Normal file
26
DataSpec/DNAMP2/PATH.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "DataSpec/DNAMP2/PATH.hpp"
|
||||
#include "hecl/Blender/Connection.hpp"
|
||||
|
||||
namespace DataSpec::DNAMP2 {
|
||||
bool PATH::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath,
|
||||
PAKRouter<PAKBridge>& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok,
|
||||
std::function<void(const hecl::SystemChar*)> fileChanged) {
|
||||
PATH path;
|
||||
path.read(rs);
|
||||
hecl::blender::Connection& conn = btok.getBlenderConnection();
|
||||
if (!conn.createBlend(outPath, hecl::blender::BlendType::PathMesh))
|
||||
return false;
|
||||
|
||||
std::string areaPath;
|
||||
for (const auto& ent : hecl::DirectoryEnumerator(outPath.getParentPath().getAbsolutePath())) {
|
||||
if (hecl::StringUtils::BeginsWith(ent.m_name, _SYS_STR("!area_"))) {
|
||||
areaPath = hecl::SystemUTF8Conv(ent.m_name).str();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const zeus::CMatrix4f* xf = pakRouter.lookupMAPATransform(entry.id);
|
||||
path.sendToBlender(conn, pakRouter.getBestEntryName(entry, false), xf, areaPath);
|
||||
return conn.saveBlend();
|
||||
}
|
||||
}
|
||||
14
DataSpec/DNAMP2/PATH.hpp
Normal file
14
DataSpec/DNAMP2/PATH.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "DataSpec/DNACommon/PATH.hpp"
|
||||
#include "DataSpec/DNAMP2/DNAMP2.hpp"
|
||||
|
||||
namespace DataSpec::DNAMP2 {
|
||||
struct PATH : DNAPATH::PATH {
|
||||
static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath,
|
||||
PAKRouter<PAKBridge>& pakRouter, const PAK::Entry& entry, bool force, hecl::blender::Token& btok,
|
||||
std::function<void(const hecl::SystemChar*)> fileChanged);
|
||||
|
||||
static bool Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath,
|
||||
const PathMesh& mesh, hecl::blender::Token& btok);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user