mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 17:04:55 +00:00
temporary ID dumping hard-coded
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "CMDL.hpp"
|
||||
#include "ANCS.hpp"
|
||||
#include "MREA.hpp"
|
||||
#include "MAPA.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
@@ -77,9 +78,11 @@ void PAKBridge::build()
|
||||
{
|
||||
Level& level = m_levelDeps[entry.id];
|
||||
|
||||
PAKEntryReadStream rs = entry.beginReadStream(m_node);
|
||||
MLVL mlvl;
|
||||
mlvl.read(rs);
|
||||
{
|
||||
PAKEntryReadStream rs = entry.beginReadStream(m_node);
|
||||
mlvl.read(rs);
|
||||
}
|
||||
#if HECL_UCS2
|
||||
level.name = HECL::UTF8ToWide(m_pak.bestEntryName(entry));
|
||||
#else
|
||||
@@ -88,6 +91,19 @@ void PAKBridge::build()
|
||||
level.areas.reserve(mlvl.areaCount);
|
||||
unsigned layerIdx = 0;
|
||||
|
||||
/* Make MAPW available to lookup MAPAs */
|
||||
const PAK::Entry* worldMapEnt = m_pak.lookupEntry(mlvl.worldMap);
|
||||
std::vector<UniqueID32> mapw;
|
||||
if (worldMapEnt)
|
||||
{
|
||||
PAKEntryReadStream rs = worldMapEnt->beginReadStream(m_node);
|
||||
rs.seek(8, Athena::Current);
|
||||
atUint32 areaCount = rs.readUint32Big();
|
||||
mapw.reserve(areaCount);
|
||||
for (atUint32 i=0 ; i<areaCount ; ++i)
|
||||
mapw.emplace_back(rs);
|
||||
}
|
||||
|
||||
/* Index areas */
|
||||
unsigned ai = 0;
|
||||
for (const MLVL::Area& area : mlvl.areas)
|
||||
@@ -98,16 +114,18 @@ void PAKBridge::build()
|
||||
if (areaNameEnt)
|
||||
{
|
||||
STRG areaName;
|
||||
PAKEntryReadStream rs = areaNameEnt->beginReadStream(m_node);
|
||||
areaName.read(rs);
|
||||
{
|
||||
PAKEntryReadStream rs = areaNameEnt->beginReadStream(m_node);
|
||||
areaName.read(rs);
|
||||
}
|
||||
areaDeps.name = areaName.getSystemString(FOURCC('ENGL'), 0);
|
||||
|
||||
/* Trim possible trailing whitespace */
|
||||
#if HECL_UCS2
|
||||
while (areaDeps.name.size() && iswblank(areaDeps.name.back()))
|
||||
while (areaDeps.name.size() && iswspace(areaDeps.name.back()))
|
||||
areaDeps.name.pop_back();
|
||||
#else
|
||||
while (areaDeps.name.size() && isblank(areaDeps.name.back()))
|
||||
while (areaDeps.name.size() && isspace(areaDeps.name.back()))
|
||||
areaDeps.name.pop_back();
|
||||
#endif
|
||||
}
|
||||
@@ -120,7 +138,7 @@ void PAKBridge::build()
|
||||
#endif
|
||||
}
|
||||
HECL::SystemChar num[16];
|
||||
HECL::SNPrintf(num, 16, _S("%02u "), ai++);
|
||||
HECL::SNPrintf(num, 16, _S("%02u "), ai);
|
||||
areaDeps.name = num + areaDeps.name;
|
||||
|
||||
areaDeps.layers.reserve(area.depLayerCount-1);
|
||||
@@ -133,10 +151,10 @@ void PAKBridge::build()
|
||||
layer.active = layerFlags.flags >> (l-1) & 0x1;
|
||||
/* Trim possible trailing whitespace */
|
||||
#if HECL_UCS2
|
||||
while (layer.name.size() && iswblank(layer.name.back()))
|
||||
while (layer.name.size() && iswspace(layer.name.back()))
|
||||
layer.name.pop_back();
|
||||
#else
|
||||
while (layer.name.size() && isblank(layer.name.back()))
|
||||
while (layer.name.size() && isspace(layer.name.back()))
|
||||
layer.name.pop_back();
|
||||
#endif
|
||||
HECL::SNPrintf(num, 16, layer.active ? _S("%02ua ") : _S("%02u "), l-1);
|
||||
@@ -146,10 +164,13 @@ void PAKBridge::build()
|
||||
for (; r<area.depLayers[l] ; ++r)
|
||||
layer.resources.emplace(area.deps[r].id);
|
||||
}
|
||||
areaDeps.resources.reserve(area.depCount - r);
|
||||
areaDeps.resources.reserve(area.depCount - r + 2);
|
||||
for (; r<area.depCount ; ++r)
|
||||
areaDeps.resources.emplace(area.deps[r].id);
|
||||
areaDeps.resources.emplace(area.areaMREAId);
|
||||
if (mapw.size() > ai)
|
||||
areaDeps.resources.emplace(mapw[ai]);
|
||||
++ai;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,6 +219,8 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const PAK::Entry& entry)
|
||||
return {nullptr, MLVL::Extract, {_S(".blend")}, 3};
|
||||
case SBIG('MREA'):
|
||||
return {nullptr, MREA::Extract, {_S(".blend")}, 4};
|
||||
case SBIG('MAPA'):
|
||||
return {nullptr, MAPA::Extract, {_S(".blend")}, 4};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "../DNACommon/DNACommon.hpp"
|
||||
#include "../DNACommon/PAK.hpp"
|
||||
#include "../DNACommon/MAPA.hpp"
|
||||
#include "DNAMP1.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
@@ -25,14 +27,36 @@ struct MAPA : BigDNA
|
||||
struct MappableObject : BigDNA
|
||||
{
|
||||
DECL_DNA
|
||||
Value<atUint32> type;
|
||||
enum Type : atUint32
|
||||
{
|
||||
MOBlueDoor = 0,
|
||||
MOShieldDoor = 1,
|
||||
MOIceDoor = 2,
|
||||
MOWaveDoor = 3,
|
||||
MOPlasmaDoor = 4,
|
||||
MOBigDoor1 = 5,
|
||||
MOBigDoor2 = 6,
|
||||
MOIceDoorCeiling = 7,
|
||||
MOIceDoorFloor = 8,
|
||||
MOWaveDoorCeiling = 9,
|
||||
MOWaveDoorFloor = 10,
|
||||
MOIceDoorFloor2 = 13,
|
||||
MOWaveDoorFloor2 = 14,
|
||||
MODownArrowYellow = 27, /* Maintenance Tunnel */
|
||||
MOUpArrowYellow = 28, /* Phazon Processing Center */
|
||||
MODownArrowGreen = 29, /* Elevator A */
|
||||
MOUpArrowGreen = 30, /* Elite Control Access */
|
||||
MODownArrowRed = 31, /* Elevator B */
|
||||
MOUpArrowRed = 32, /* Fungal Hall Access */
|
||||
MOTransportLift = 33,
|
||||
MOSaveStation = 34,
|
||||
MOMissileStation = 37
|
||||
};
|
||||
Value<Type> type;
|
||||
Value<atUint32> unknown1;
|
||||
Value<atUint16> unknown2;
|
||||
Value<atUint16> id;
|
||||
Value<atUint32> sclyId;
|
||||
Seek<DNA_COUNT(4), Athena::Current> seek1;
|
||||
Value<atVec4f> transform1;
|
||||
Value<atVec4f> transform2;
|
||||
Value<atVec4f> transform3;
|
||||
Value<atVec4f> transformMtx[3];
|
||||
Seek<DNA_COUNT(0x10), Athena::Current> seek2;
|
||||
};
|
||||
Vector<MappableObject, DNA_COUNT(mappableObjectCount)> mappableObjects;
|
||||
@@ -42,9 +66,9 @@ struct MAPA : BigDNA
|
||||
{
|
||||
DECL_DNA
|
||||
Value<atVec3f> normal;
|
||||
Value<atVec3f> center;
|
||||
Value<atUint32> start;
|
||||
Value<atUint32> end;
|
||||
Value<atVec3f> centroid;
|
||||
Value<atUint32> polyOff;
|
||||
Value<atUint32> edgeOff;
|
||||
};
|
||||
|
||||
Vector<SurfaceHeader, DNA_COUNT(surfaceCount)> surfaceHeaders;
|
||||
@@ -58,7 +82,7 @@ struct MAPA : BigDNA
|
||||
DECL_DNA
|
||||
Value<atUint32> type;
|
||||
Value<atUint32> indexCount;
|
||||
Vector<atUint32, DNA_COUNT(indexCount)> indices;
|
||||
Vector<atUint8, DNA_COUNT(indexCount)> indices;
|
||||
Align<4> align;
|
||||
};
|
||||
Vector<Primitive, DNA_COUNT(primitiveCount)> primitives;
|
||||
@@ -67,13 +91,27 @@ struct MAPA : BigDNA
|
||||
{
|
||||
DECL_DNA
|
||||
Value<atUint32> indexCount;
|
||||
Vector<atUint32, DNA_COUNT(indexCount)> indices;
|
||||
Vector<atUint8, DNA_COUNT(indexCount)> indices;
|
||||
Align<4> align;
|
||||
};
|
||||
Vector<Border, DNA_COUNT(borderCount)> borders;
|
||||
};
|
||||
|
||||
Vector<Surface, DNA_COUNT(surfaceCount)> surfaces;
|
||||
|
||||
static bool Extract(const SpecBase& dataSpec,
|
||||
PAKEntryReadStream& rs,
|
||||
const HECL::ProjectPath& outPath,
|
||||
PAKRouter<PAKBridge>& pakRouter,
|
||||
const PAK::Entry& entry,
|
||||
bool force,
|
||||
std::function<void(const HECL::SystemChar*)> fileChanged)
|
||||
{
|
||||
MAPA mapa;
|
||||
mapa.read(rs);
|
||||
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
|
||||
return DNAMAPA::ReadMAPAToBlender(conn, mapa, outPath, pakRouter, entry, force);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +116,9 @@ struct MLVL : BigYAML
|
||||
{
|
||||
MLVL mlvl;
|
||||
mlvl.read(rs);
|
||||
FILE* fp = HECL::Fopen(outPath.getWithExtension(_S(".yaml"), true).getAbsolutePath().c_str(), _S("w"));
|
||||
mlvl.toYAMLFile(fp);
|
||||
fclose(fp);
|
||||
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
|
||||
return DNAMLVL::ReadMLVLToBlender(conn, mlvl, outPath, pakRouter,
|
||||
entry, force, fileChanged);
|
||||
|
||||
@@ -46,13 +46,18 @@ bool MREA::Extract(const SpecBase& dataSpec,
|
||||
using RigPair = std::pair<CSKR*, CINF*>;
|
||||
RigPair dummy(nullptr, nullptr);
|
||||
|
||||
/* Rename MREA for consistency */
|
||||
HECL::ProjectPath mreaPath(outPath.getParentPath(), _S("!area.blend"));
|
||||
if (!force && mreaPath.getPathType() == HECL::ProjectPath::PT_FILE)
|
||||
return true;
|
||||
|
||||
/* Do extract */
|
||||
Header head;
|
||||
head.read(rs);
|
||||
rs.seekAlign32();
|
||||
|
||||
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
|
||||
if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeArea))
|
||||
if (!conn.createBlend(mreaPath, HECL::BlenderConnection::TypeArea))
|
||||
return false;
|
||||
|
||||
/* Open Py Stream and read sections */
|
||||
|
||||
@@ -27,6 +27,8 @@ void PAK::read(Athena::io::IStreamReader& reader)
|
||||
atUint32 count = reader.readUint32Big();
|
||||
m_entries.clear();
|
||||
m_entries.reserve(count);
|
||||
m_firstEntries.clear();
|
||||
m_firstEntries.reserve(count);
|
||||
m_idMap.clear();
|
||||
m_idMap.reserve(count);
|
||||
for (atUint32 e=0 ; e<count ; ++e)
|
||||
@@ -38,7 +40,14 @@ void PAK::read(Athena::io::IStreamReader& reader)
|
||||
ent.compressed = 2;
|
||||
}
|
||||
for (Entry& entry : m_entries)
|
||||
m_idMap[entry.id] = &entry;
|
||||
{
|
||||
auto search = m_idMap.find(entry.id);
|
||||
if (search == m_idMap.end())
|
||||
{
|
||||
m_firstEntries.push_back(&entry);
|
||||
m_idMap[entry.id] = &entry;
|
||||
}
|
||||
}
|
||||
|
||||
m_nameMap.clear();
|
||||
m_nameMap.reserve(nameCount);
|
||||
|
||||
@@ -48,6 +48,7 @@ struct PAK : BigDNA
|
||||
|
||||
std::vector<NameEntry> m_nameEntries;
|
||||
std::vector<Entry> m_entries;
|
||||
std::vector<Entry*> m_firstEntries;
|
||||
std::unordered_map<UniqueID32, Entry*> m_idMap;
|
||||
std::unordered_map<std::string, Entry*> m_nameMap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user