mirror of https://github.com/AxioDL/metaforce.git
Implement Oculus loader
This commit is contained in:
parent
9312eef905
commit
1d3e5cdb70
|
@ -69,6 +69,7 @@ static const std::unordered_set<uint32_t> IndividualOrigIDs = {
|
|||
|
||||
struct OriginalIDs {
|
||||
static void Generate(PAKRouter<DNAMP1::PAKBridge>& pakRouter, hecl::Database::Project& project) {
|
||||
Log.report(logvisor::Level::Info, fmt("Generating Original ID mappings..."));
|
||||
std::unordered_set<UniqueID32> addedIDs;
|
||||
std::vector<UniqueID32> originalIDs;
|
||||
|
||||
|
@ -93,6 +94,7 @@ struct OriginalIDs {
|
|||
path.makeDirChain(false);
|
||||
athena::io::FileWriter fileW(path.getAbsolutePath());
|
||||
yamlW.finish(&fileW);
|
||||
Log.report(logvisor::Level::Info, fmt("Done"));
|
||||
}
|
||||
|
||||
static void Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath) {
|
||||
|
@ -138,6 +140,7 @@ struct OriginalIDs {
|
|||
|
||||
struct TextureCache {
|
||||
static void Generate(PAKRouter<DNAMP1::PAKBridge>& pakRouter, hecl::Database::Project& project) {
|
||||
Log.report(logvisor::Level::Info, fmt("Gathering Texture metadata (this can take up to 10 seconds)..."));
|
||||
std::unordered_map<UniqueID32, TXTR::Meta> metaMap;
|
||||
|
||||
pakRouter.enumerateResources([&](const DNAMP1::PAK::Entry* ent) {
|
||||
|
@ -159,6 +162,36 @@ struct TextureCache {
|
|||
path.makeDirChain(false);
|
||||
athena::io::FileWriter fileW(path.getAbsolutePath());
|
||||
yamlW.finish(&fileW);
|
||||
Log.report(logvisor::Level::Info, fmt("Done..."));
|
||||
}
|
||||
|
||||
static void Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath) {
|
||||
hecl::Database::Project& project = inPath.getProject();
|
||||
athena::io::YAMLDocReader r;
|
||||
athena::io::FileReader fr(inPath.getAbsolutePath());
|
||||
if (!fr.isOpen() || !r.parse(&fr))
|
||||
return;
|
||||
|
||||
std::vector<std::pair<UniqueID32, TXTR::Meta>> metaPairs;
|
||||
metaPairs.reserve(r.getRootNode()->m_mapChildren.size());
|
||||
for (const auto& node : r.getRootNode()->m_mapChildren) {
|
||||
hecl::ProjectPath projectPath(project, node.first);
|
||||
auto rec = r.enterSubRecord(node.first.c_str());
|
||||
TXTR::Meta meta;
|
||||
meta.read(r);
|
||||
metaPairs.push_back(std::make_pair(projectPath.hash().val32(), meta));
|
||||
}
|
||||
|
||||
std::sort(metaPairs.begin(), metaPairs.end(), [](const auto& a, const auto& b) -> bool {
|
||||
return a.first < b.first;
|
||||
});
|
||||
|
||||
athena::io::FileWriter w(outPath.getAbsolutePath());
|
||||
w.writeUint32Big(metaPairs.size());
|
||||
for (const auto& pair : metaPairs) {
|
||||
pair.first.write(w);
|
||||
pair.second.write(w);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -504,6 +537,8 @@ struct SpecMP1 : SpecBase {
|
|||
return true;
|
||||
else if (!strcmp(classType, "MP1OriginalIDs"))
|
||||
return true;
|
||||
else if (!strcmp(classType, "MP1TextureCache"))
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
@ -657,6 +692,9 @@ struct SpecMP1 : SpecBase {
|
|||
} else if (!strcmp(className, "MP1OriginalIDs")) {
|
||||
resTag.type = SBIG('OIDS');
|
||||
return true;
|
||||
} else if (!strcmp(className, "MP1TextureCache")) {
|
||||
resTag.type = SBIG('TMET');
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -947,6 +985,8 @@ struct SpecMP1 : SpecBase {
|
|||
DNAMP1::AFSM::Cook(in, out);
|
||||
} else if (!classStr.compare("MP1OriginalIDs")) {
|
||||
OriginalIDs::Cook(in, out);
|
||||
} else if (!classStr.compare("MP1TextureCache")) {
|
||||
TextureCache::Cook(in, out);
|
||||
}
|
||||
}
|
||||
progress(_SYS_STR("Done"));
|
||||
|
|
|
@ -2977,7 +2977,35 @@ CEntity* ScriptLoader::LoadActorContraption(CStateManager& mgr, CInputStream& in
|
|||
}
|
||||
|
||||
CEntity* ScriptLoader::LoadOculus(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
|
||||
if (!EnsurePropertyCount(propCount, 15, "Oculus"))
|
||||
return nullptr;
|
||||
|
||||
SScaledActorHead aHead = LoadScaledActorHead(in, mgr);
|
||||
auto pair = CPatternedInfo::HasCorrectParameterCount(in);
|
||||
if (!pair.first)
|
||||
return nullptr;
|
||||
CPatternedInfo pInfo(in, pair.second);
|
||||
CActorParameters actParms = LoadActorParameters(in);
|
||||
if (!pInfo.GetAnimationParameters().GetACSFile().IsValid())
|
||||
return nullptr;
|
||||
|
||||
float f1 = in.readFloatBig();
|
||||
float f2 = in.readFloatBig();
|
||||
float f3 = in.readFloatBig();
|
||||
float f4 = in.readFloatBig();
|
||||
float f5 = in.readFloatBig();
|
||||
float f6 = in.readFloatBig();
|
||||
CDamageVulnerability dVuln(in);
|
||||
float f7 = in.readFloatBig();
|
||||
CDamageInfo dInfo(in);
|
||||
const CAnimationParameters animParms = pInfo.GetAnimationParameters();
|
||||
CModelData mData(CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), aHead.x40_scale,
|
||||
animParms.GetInitialAnimation(), true));
|
||||
|
||||
return new MP1::CParasite(
|
||||
mgr.AllocateUniqueId(), aHead.x0_name, CPatterned::EFlavorType::Zero, info, aHead.x10_transform, std::move(mData),
|
||||
pInfo, EBodyType::WallWalker, 0.f, f1, f2, f3, f4, 0.2f, 0.4f, 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, f7, 0.f, 0.f, f5, f6,
|
||||
false, CWallWalker::EWalkerType::Oculus, dVuln, dInfo, -1, -1, -1, CAssetId(), CAssetId(), 0.f, actParms);
|
||||
}
|
||||
|
||||
CEntity* ScriptLoader::LoadGeemer(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
|
||||
|
|
Loading…
Reference in New Issue