mirror of https://github.com/AxioDL/metaforce.git
Character cooking fixes
This commit is contained in:
parent
5eab081c60
commit
bf049843e1
|
@ -22,7 +22,6 @@ AlwaysBreakAfterDefinitionReturnType: None
|
|||
AllowShortFunctionsOnASingleLine: All
|
||||
Cpp11BracedListStyle: true
|
||||
NamespaceIndentation: None
|
||||
ReflowComments: true
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
SortIncludes: false
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace DataSpec
|
||||
{
|
||||
extern hecl::Database::DataSpecEntry SpecEntMP1;
|
||||
extern hecl::Database::DataSpecEntry SpecEntMP1PC;
|
||||
|
||||
namespace DNAMP1
|
||||
|
@ -1075,6 +1076,7 @@ bool ANCS::Extract(const SpecBase& dataSpec,
|
|||
bool ANCS::Cook(const hecl::ProjectPath& outPath,
|
||||
const hecl::ProjectPath& inPath,
|
||||
const DNAANCS::Actor& actor,
|
||||
hecl::BlenderConnection::DataStream& ds,
|
||||
const std::function<bool(const hecl::ProjectPath& modelPath)>& modelCookFunc)
|
||||
{
|
||||
/* Search for yaml */
|
||||
|
@ -1138,30 +1140,52 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
|
|||
});
|
||||
|
||||
std::unordered_map<std::string, atInt32> boneIdMap;
|
||||
std::experimental::optional<DNAANIM::RigInverter<CINF>> rigInv;
|
||||
|
||||
/* Write out CINF resources */
|
||||
for (const DNAANCS::Actor::Armature& arm : actor.armatures)
|
||||
{
|
||||
hecl::SystemStringView sysStr(arm.name);
|
||||
hecl::ProjectPath pathOut = inPath.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true).ensureAuxInfo(_S("CINF"));
|
||||
hecl::ProjectPath pathOut = inPath.getCookedPath(SpecEntMP1).getWithExtension((_S('.') +
|
||||
sysStr.sys_str()).c_str(), true).ensureAuxInfo(_S("CINF"));
|
||||
athena::io::FileWriter w(pathOut.getAbsolutePath(), true, false);
|
||||
if (w.hasError())
|
||||
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
|
||||
pathOut.getRelativePath().c_str());
|
||||
CINF cinf(arm, boneIdMap);
|
||||
cinf.write(w);
|
||||
|
||||
if (!rigInv)
|
||||
{
|
||||
auto matrices = ds.getBoneMatrices(arm.name);
|
||||
rigInv.emplace(cinf, matrices);
|
||||
}
|
||||
}
|
||||
ds.close();
|
||||
|
||||
/* Write out CSKR resources */
|
||||
for (ANCS::CharacterSet::CharacterInfo& ch : ancs.characterSet.characters)
|
||||
{
|
||||
hecl::ProjectPath modelPath = UniqueIDBridge::TranslatePakIdToPath(ch.cmdl);
|
||||
const DNAANCS::Actor::Subtype* subtype = nullptr;
|
||||
for (const DNAANCS::Actor::Subtype& sub : actor.subtypes)
|
||||
{
|
||||
if (!sub.name.compare(ch.name))
|
||||
{
|
||||
subtype = ⊂
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!subtype)
|
||||
Log.report(logvisor::Fatal, "unable to find subtype '%s'", ch.name.c_str());
|
||||
|
||||
const hecl::ProjectPath& modelPath = subtype->mesh;
|
||||
|
||||
if (modelPath.getPathType() != hecl::ProjectPath::Type::File)
|
||||
Log.report(logvisor::Fatal, _S("unable to resolve '%s'"), modelPath.getRelativePath().c_str());
|
||||
|
||||
hecl::ProjectPath skinIntPath = modelPath.getCookedPath(SpecEntMP1PC).getWithExtension(_S(".skinint"));
|
||||
if (skinIntPath.getModtime() < modelPath.getModtime())
|
||||
if (skinIntPath.getPathType() != hecl::ProjectPath::Type::File ||
|
||||
skinIntPath.getModtime() < modelPath.getModtime())
|
||||
if (!modelCookFunc(modelPath))
|
||||
Log.report(logvisor::Fatal, _S("unable to cook '%s'"), modelPath.getRelativePath().c_str());
|
||||
|
||||
|
@ -1194,7 +1218,8 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
|
|||
skinIO.close();
|
||||
|
||||
hecl::SystemStringView sysStr(ch.name);
|
||||
hecl::ProjectPath skinPath = inPath.getCookedPath(SpecEntMP1PC).getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true).ensureAuxInfo(_S("CSKR"));
|
||||
hecl::ProjectPath skinPath = inPath.getCookedPath(SpecEntMP1PC).getWithExtension((_S('.') +
|
||||
sysStr.sys_str()).c_str(), true).ensureAuxInfo(_S("CSKR"));
|
||||
athena::io::FileWriter skinOut(skinPath.getAbsolutePath(), true, false);
|
||||
if (skinOut.hasError())
|
||||
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
|
||||
|
@ -1222,11 +1247,12 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
|
|||
{
|
||||
hecl::SystemStringView sysStr(act.name);
|
||||
hecl::ProjectPath pathOut = inPath.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true).ensureAuxInfo(_S("ANIM"));
|
||||
athena::io::FileWriter w(pathOut.getAbsolutePath(), true, false);
|
||||
hecl::ProjectPath cookedOut = inPath.getCookedPath(SpecEntMP1).getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true);
|
||||
athena::io::FileWriter w(cookedOut.getAbsolutePath(), true, false);
|
||||
if (w.hasError())
|
||||
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
|
||||
pathOut.getRelativePath().c_str());
|
||||
ANIM anim(act, boneIdMap);
|
||||
cookedOut.getRelativePath().c_str());
|
||||
ANIM anim(act, boneIdMap, *rigInv);
|
||||
|
||||
ancs.animationSet.animResources.emplace_back();
|
||||
ancs.animationSet.animResources.back().animId = pathOut;
|
||||
|
@ -1245,7 +1271,7 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
|
|||
fclose(fp);
|
||||
anim.m_anim->evnt = evntYamlPath;
|
||||
|
||||
hecl::ProjectPath evntYamlOut = pathOut.getWithExtension(_S(".evnt"));
|
||||
hecl::ProjectPath evntYamlOut = cookedOut.getWithExtension(_S(".evnt"));
|
||||
athena::io::FileWriter w(evntYamlOut.getAbsolutePath(), true, false);
|
||||
if (w.hasError())
|
||||
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
|
||||
|
|
|
@ -539,6 +539,7 @@ struct ANCS : BigYAML
|
|||
static bool Cook(const hecl::ProjectPath& outPath,
|
||||
const hecl::ProjectPath& inPath,
|
||||
const DNAANCS::Actor& actor,
|
||||
hecl::BlenderConnection::DataStream& ds,
|
||||
const std::function<bool(const hecl::ProjectPath& modelPath)>& modelCookFunc);
|
||||
};
|
||||
|
||||
|
|
|
@ -422,7 +422,9 @@ size_t ANIM::ANIM2::binarySize(size_t __isz) const
|
|||
return __isz + DNAANIM::ComputeBitstreamSize(frames.size(), channels);
|
||||
}
|
||||
|
||||
ANIM::ANIM(const BlenderAction& act, const std::unordered_map<std::string, atInt32>& idMap)
|
||||
ANIM::ANIM(const BlenderAction& act,
|
||||
const std::unordered_map<std::string, atInt32>& idMap,
|
||||
const DNAANIM::RigInverter<CINF>& rig)
|
||||
{
|
||||
m_anim.reset(new struct ANIM0);
|
||||
IANIM& newAnim = *m_anim;
|
||||
|
@ -465,10 +467,9 @@ ANIM::ANIM(const BlenderAction& act, const std::unordered_map<std::string, atInt
|
|||
rotVals.reserve(chan.keys.size());
|
||||
for (const BlenderAction::Channel::Key& key : chan.keys)
|
||||
{
|
||||
rotVals.emplace_back(key.rotation.val.vec[0],
|
||||
key.rotation.val.vec[1],
|
||||
key.rotation.val.vec[2],
|
||||
key.rotation.val.vec[3]);
|
||||
zeus::CQuaternion q(key.rotation.val);
|
||||
q = rig.restoreRotation(newChan.id, q);
|
||||
rotVals.emplace_back(q.w, q.x, q.y, q.z);
|
||||
}
|
||||
|
||||
if (chan.attrMask & 0x2)
|
||||
|
@ -483,9 +484,9 @@ ANIM::ANIM(const BlenderAction& act, const std::unordered_map<std::string, atInt
|
|||
transVals.reserve(chan.keys.size());
|
||||
for (const BlenderAction::Channel::Key& key : chan.keys)
|
||||
{
|
||||
transVals.emplace_back(key.position.val.vec[0],
|
||||
key.position.val.vec[1],
|
||||
key.position.val.vec[2]);
|
||||
zeus::CVector3f pos(key.position.val);
|
||||
pos = rig.restorePosition(newChan.id, pos, true);
|
||||
transVals.emplace_back(pos.x, pos.y, pos.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -182,7 +182,9 @@ struct ANIM : BigDNA
|
|||
using BlenderAction = hecl::BlenderConnection::DataStream::Actor::Action;
|
||||
|
||||
ANIM() = default;
|
||||
ANIM(const BlenderAction& act, const std::unordered_map<std::string, atInt32>& idMap);
|
||||
ANIM(const BlenderAction& act,
|
||||
const std::unordered_map<std::string, atInt32>& idMap,
|
||||
const DNAANIM::RigInverter<CINF>& rig);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ CINF::CINF(const Armature& armature, std::unordered_map<std::string, atInt32>& i
|
|||
if (bone->children.size())
|
||||
{
|
||||
int curId = 4;
|
||||
RecursiveAddArmatureBone(armature, armature.getChild(bone, 0), 3, curId, idMap, nameMap);
|
||||
RecursiveAddArmatureBone(armature, bone, 3, curId, idMap, nameMap);
|
||||
}
|
||||
|
||||
bones.emplace_back();
|
||||
|
|
|
@ -354,7 +354,7 @@ struct SpecMP1 : SpecBase
|
|||
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
|
||||
FCookProgress progress)
|
||||
{
|
||||
Mesh mesh = ds.compileMesh(fast ? hecl::HMDLTopology::Triangles : hecl::HMDLTopology::TriStrips, -1,
|
||||
Mesh mesh = ds.compileMesh(fast ? hecl::HMDLTopology::Triangles : hecl::HMDLTopology::TriStrips, m_pc ? 16 : -1,
|
||||
[&progress](int surfCount)
|
||||
{
|
||||
progress(hecl::SysFormat(_S("%d"), surfCount).c_str());
|
||||
|
@ -371,7 +371,7 @@ struct SpecMP1 : SpecBase
|
|||
FCookProgress progress)
|
||||
{
|
||||
Actor actor = ds.compileActor();
|
||||
DNAMP1::ANCS::Cook(out, in, actor,
|
||||
DNAMP1::ANCS::Cook(out, in, actor, ds,
|
||||
[&](const hecl::ProjectPath& modelPath) -> bool
|
||||
{
|
||||
hecl::ProjectPath cooked;
|
||||
|
|
|
@ -26,6 +26,8 @@ namespace urde
|
|||
|
||||
void ViewManager::BuildTestPART(urde::IObjectStore& objStore)
|
||||
{
|
||||
m_modelTest = objStore.GetObj("MP1/Shared/CMDL_B2B41738.blend");
|
||||
CModel* ridley = m_modelTest.GetObj();
|
||||
#if 1
|
||||
SObjectTag samusCharSet = m_projManager.TagFromPath(_S("MP1/Shared/ANCS_77289A4A.blend"));
|
||||
SObjectTag platModel = m_projManager.TagFromPath(_S("MP1/Shared/CMDL_6FA561D0.blend"));
|
||||
|
@ -41,7 +43,7 @@ void ViewManager::BuildTestPART(urde::IObjectStore& objStore)
|
|||
auto areaData = m_projManager.resourceFactoryMP1().LoadResourceSync(areaTag);
|
||||
|
||||
//m_modelTest = objStore.GetObj("gun_cmdl");
|
||||
m_modelTest = objStore.GetObj("MP1/Shared/CMDL_B2B41738.blend");
|
||||
|
||||
//m_modelTest = objStore.GetObj("CMDL_GameCube");
|
||||
|
||||
//m_partGenDesc = objStore.GetObj({hecl::FOURCC('PART'), 0x972A5CD2});
|
||||
|
|
2
amuse
2
amuse
|
@ -1 +1 @@
|
|||
Subproject commit 055e73183ac86ee9bedb65802149516bd2d821a1
|
||||
Subproject commit 28cac7ff8373e0386d44492f27e717d6dee0e44a
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
|||
Subproject commit 667c476f2e78ac6aedef9faba4783ade01dfbd47
|
||||
Subproject commit 3bc81a3fe2711d9d7817e6f24afe7e29ca5e99d3
|
2
specter
2
specter
|
@ -1 +1 @@
|
|||
Subproject commit 4260ea58f19648d6548b0c25488bfb8b47d0263b
|
||||
Subproject commit 5e695dab622d5095120224297b3c2fea4b3b85ca
|
Loading…
Reference in New Issue