mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 16:24:55 +00:00
Lots of reverse naming functionality added
This commit is contained in:
@@ -1024,6 +1024,36 @@ bool ReadCMDLToBlender(HECL::BlenderConnection& conn,
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class PAKRouter, class MaterialSet>
|
||||
void NameCMDL(Athena::io::IStreamReader& reader,
|
||||
PAKRouter& pakRouter,
|
||||
typename PAKRouter::EntryType& entry,
|
||||
const SpecBase& dataspec)
|
||||
{
|
||||
Header head;
|
||||
head.read(reader);
|
||||
std::string bestName = HECL::Format("CMDL_%s", entry.id.toString().c_str());
|
||||
|
||||
/* Pre-read pass to determine maximum used vert indices */
|
||||
atUint32 matSecCount = 0;
|
||||
if (head.matSetCount)
|
||||
matSecCount = MaterialSet::OneSection() ? 1 : head.matSetCount;
|
||||
atUint32 lastDlSec = head.secCount;
|
||||
for (size_t s=0 ; s<lastDlSec ; ++s)
|
||||
{
|
||||
atUint64 secStart = reader.position();
|
||||
if (s < matSecCount)
|
||||
{
|
||||
MaterialSet matSet;
|
||||
matSet.read(reader);
|
||||
matSet.nameTextures(pakRouter, bestName.c_str(), s);
|
||||
}
|
||||
|
||||
if (s < head.secCount - 1)
|
||||
reader.seek(secStart + head.secSizes[s], Athena::Begin);
|
||||
}
|
||||
}
|
||||
|
||||
static void WriteDLVal(Athena::io::FileWriter& writer, GX::AttrType type, atUint32 val)
|
||||
{
|
||||
switch (type)
|
||||
|
||||
@@ -50,7 +50,7 @@ class UniqueID32 : public BigYAML
|
||||
uint32_t m_id = 0xffffffff;
|
||||
public:
|
||||
Delete expl;
|
||||
operator bool() const {return m_id != 0xffffffff;}
|
||||
operator bool() const {return m_id != 0xffffffff && m_id != 0;}
|
||||
void read(Athena::io::IStreamReader& reader)
|
||||
{m_id = reader.readUint32Big();}
|
||||
void write(Athena::io::IStreamWriter& writer) const
|
||||
@@ -89,7 +89,7 @@ class UniqueID64 : public BigYAML
|
||||
uint64_t m_id = 0xffffffffffffffff;
|
||||
public:
|
||||
Delete expl;
|
||||
operator bool() const {return m_id != 0xffffffffffffffff;}
|
||||
operator bool() const {return m_id != 0xffffffffffffffff && m_id != 0;}
|
||||
void read(Athena::io::IStreamReader& reader)
|
||||
{m_id = reader.readUint64Big();}
|
||||
void write(Athena::io::IStreamWriter& writer) const
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
Delete expl;
|
||||
UniqueID128() {m_id[0]=0xffffffffffffffff; m_id[1]=0xffffffffffffffff;}
|
||||
operator bool() const
|
||||
{return m_id[0] != 0xffffffffffffffff && m_id[1] != 0xffffffffffffffff;}
|
||||
{return m_id[0] != 0xffffffffffffffff && m_id[0] != 0 && m_id[1] != 0xffffffffffffffff && m_id[1] != 0;}
|
||||
void read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
m_id[0] = reader.readUint64Big();
|
||||
|
||||
@@ -206,6 +206,8 @@ struct ResExtractor
|
||||
std::function<void(const HECL::SystemChar*)>)> func_b;
|
||||
const HECL::SystemChar* fileExts[4];
|
||||
unsigned weight;
|
||||
std::function<void(const SpecBase&, PAKEntryReadStream&, PAKRouter<PAKBRIDGE>&,
|
||||
typename PAKBRIDGE::PAKType::Entry&)> func_name;
|
||||
};
|
||||
|
||||
/* Level hierarchy representation */
|
||||
@@ -304,18 +306,41 @@ public:
|
||||
}
|
||||
|
||||
/* Add RigPairs to global map */
|
||||
bridge.addCMDLRigPairs(m_cmdlRigs);
|
||||
bridge.addCMDLRigPairs(*this, m_cmdlRigs);
|
||||
|
||||
progress(++count / bridgesSz);
|
||||
++bridgeIdx;
|
||||
}
|
||||
|
||||
/* TEMP: CSV dump */
|
||||
for (auto& entry : m_uniqueEntries)
|
||||
{
|
||||
const NOD::Node* node;
|
||||
EntryType* ent = (EntryType*)lookupEntry(entry.first, &node);
|
||||
ResExtractor<BRIDGETYPE> extractor = BRIDGETYPE::LookupExtractor(*ent);
|
||||
if (extractor.func_name)
|
||||
{
|
||||
PAKEntryReadStream s = ent->beginReadStream(*node);
|
||||
extractor.func_name(m_dataSpec, s, *this, *ent);
|
||||
}
|
||||
}
|
||||
for (const auto& entry : m_sharedEntries)
|
||||
{
|
||||
const NOD::Node* node;
|
||||
EntryType* ent = (EntryType*)lookupEntry(entry.first, &node);
|
||||
ResExtractor<BRIDGETYPE> extractor = BRIDGETYPE::LookupExtractor(*ent);
|
||||
if (extractor.func_name)
|
||||
{
|
||||
PAKEntryReadStream s = ent->beginReadStream(*node);
|
||||
extractor.func_name(m_dataSpec, s, *this, *ent);
|
||||
}
|
||||
}
|
||||
|
||||
FILE* fp = HECL::Fopen(_S("/home/jacko/Desktop/mp_res.txt"), _S("w"));
|
||||
for (const auto& entry : m_uniqueEntries)
|
||||
for (auto& entry : m_uniqueEntries)
|
||||
{
|
||||
const EntryType* ent = entry.second.second;
|
||||
fprintf(fp, "%s\t0x%s\t\t", ent->type.toString().c_str(), entry.first.toString().c_str());
|
||||
fprintf(fp, "%s\t0x%s\t%s\t", ent->type.toString().c_str(), entry.first.toString().c_str(), ent->name.c_str());
|
||||
switch (ent->unique.m_type)
|
||||
{
|
||||
case UniqueResult::UNIQUE_NOTFOUND:
|
||||
@@ -343,7 +368,7 @@ public:
|
||||
for (const auto& entry : m_sharedEntries)
|
||||
{
|
||||
const EntryType* ent = entry.second.second;
|
||||
fprintf(fp, "%s\t0x%s\t\t\n", ent->type.toString().c_str(), entry.first.toString().c_str());
|
||||
fprintf(fp, "%s\t0x%s\t%s\t\n", ent->type.toString().c_str(), entry.first.toString().c_str(), ent->name.c_str());
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user