mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 17:44:56 +00:00
Migration to new ANIM extract
This commit is contained in:
@@ -243,9 +243,6 @@ void ANCS::CharacterSet::CharacterInfo::read(athena::io::YAMLDocReader& reader)
|
||||
idx = reader.readUint32("idx");
|
||||
atUint16 sectionCount = reader.readUint16("sectionCount");
|
||||
name = reader.readString("name");
|
||||
reader.enumerate("cmdl", cmdl);
|
||||
reader.enumerate("cskr", cskr);
|
||||
reader.enumerate("cinf", cinf);
|
||||
|
||||
reader.enumerate("animations", animations);
|
||||
|
||||
@@ -280,7 +277,6 @@ void ANCS::CharacterSet::CharacterInfo::read(athena::io::YAMLDocReader& reader)
|
||||
if (sectionCount > 3)
|
||||
{
|
||||
reader.enumerate("cmdlOverlay", cmdlOverlay);
|
||||
reader.enumerate("cskrOverlay", cskrOverlay);
|
||||
}
|
||||
|
||||
animIdxs.clear();
|
||||
@@ -321,8 +317,6 @@ void ANCS::CharacterSet::CharacterInfo::write(athena::io::YAMLDocWriter& writer)
|
||||
|
||||
writer.writeString("name", name);
|
||||
writer.enumerate("cmdl", cmdl);
|
||||
writer.enumerate("cskr", cskr);
|
||||
writer.enumerate("cinf", cinf);
|
||||
|
||||
writer.enumerate("animations", animations);
|
||||
|
||||
@@ -355,7 +349,6 @@ void ANCS::CharacterSet::CharacterInfo::write(athena::io::YAMLDocWriter& writer)
|
||||
if (sectionCount > 3)
|
||||
{
|
||||
writer.enumerate("cmdlOverlay", cmdlOverlay);
|
||||
writer.enumerate("cskrOverlay", cskrOverlay);
|
||||
}
|
||||
|
||||
if (sectionCount > 4)
|
||||
@@ -381,23 +374,10 @@ void ANCS::AnimationSet::read(athena::io::IStreamReader& reader)
|
||||
atUint16 sectionCount = reader.readUint16Big();
|
||||
|
||||
atUint32 animationCount = reader.readUint32Big();
|
||||
animations.clear();
|
||||
animations.reserve(animationCount);
|
||||
for (atUint32 i=0 ; i<animationCount ; ++i)
|
||||
{
|
||||
animations.emplace_back(m_ancsId);
|
||||
animations.back().read(reader);
|
||||
}
|
||||
reader.enumerate(animations, animationCount);
|
||||
|
||||
atUint32 transitionCount = reader.readUint32Big();
|
||||
transitions.clear();
|
||||
transitions.reserve(transitionCount);
|
||||
for (atUint32 i=0 ; i<transitionCount ; ++i)
|
||||
{
|
||||
transitions.emplace_back(m_ancsId);
|
||||
transitions.back().read(reader);
|
||||
}
|
||||
|
||||
reader.enumerate(transitions, transitionCount);
|
||||
defaultTransition.read(reader);
|
||||
|
||||
additiveAnims.clear();
|
||||
@@ -412,14 +392,8 @@ void ANCS::AnimationSet::read(athena::io::IStreamReader& reader)
|
||||
halfTransitions.clear();
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
atUint32 halfTransitionCount = reader.readUint32Big();
|
||||
halfTransitions.clear();
|
||||
halfTransitions.reserve(halfTransitionCount);
|
||||
for (atUint32 i=0 ; i<halfTransitionCount ; ++i)
|
||||
{
|
||||
halfTransitions.emplace_back(m_ancsId);
|
||||
halfTransitions.back().read(reader);
|
||||
}
|
||||
atUint32 halfTransitionCount = reader.readUint32Big();
|
||||
reader.enumerate(halfTransitions, halfTransitionCount);
|
||||
}
|
||||
|
||||
evnts.clear();
|
||||
@@ -517,32 +491,9 @@ void ANCS::AnimationSet::read(athena::io::YAMLDocReader& reader)
|
||||
{
|
||||
atUint16 sectionCount = reader.readUint16("sectionCount");
|
||||
|
||||
size_t animationCount;
|
||||
reader.enterSubVector("animations", animationCount);
|
||||
animations.clear();
|
||||
animations.reserve(animationCount);
|
||||
for (size_t i=0 ; i<animationCount ; ++i)
|
||||
{
|
||||
animations.emplace_back(m_ancsId);
|
||||
reader.enterSubRecord(nullptr);
|
||||
animations.back().read(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
|
||||
size_t transitionCount;
|
||||
reader.enterSubVector("transitions", transitionCount);
|
||||
transitions.clear();
|
||||
transitions.reserve(transitionCount);
|
||||
for (size_t i=0 ; i<transitionCount ; ++i)
|
||||
{
|
||||
transitions.emplace_back(m_ancsId);
|
||||
reader.enterSubRecord(nullptr);
|
||||
transitions.back().read(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("animations", animations);
|
||||
|
||||
reader.enumerate("transitions", transitions);
|
||||
reader.enumerate("defaultTransition", defaultTransition);
|
||||
|
||||
additiveAnims.clear();
|
||||
@@ -556,17 +507,7 @@ void ANCS::AnimationSet::read(athena::io::YAMLDocReader& reader)
|
||||
halfTransitions.clear();
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
size_t halfTransitionCount;
|
||||
reader.enterSubVector("halfTransitions", halfTransitionCount);
|
||||
halfTransitions.reserve(halfTransitionCount);
|
||||
for (size_t i=0 ; i<halfTransitionCount ; ++i)
|
||||
{
|
||||
halfTransitions.emplace_back(m_ancsId);
|
||||
reader.enterSubRecord(nullptr);
|
||||
halfTransitions.back().read(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("halfTransitions", halfTransitions);
|
||||
}
|
||||
|
||||
evnts.clear();
|
||||
|
||||
@@ -22,8 +22,6 @@ struct ANCS : BigYAML
|
||||
using CSKRType = CSKR;
|
||||
using ANIMType = ANIM;
|
||||
|
||||
ANCS(const UniqueID32& ancsId) : animationSet(ancsId) {}
|
||||
|
||||
DECL_YAML
|
||||
Value<atUint16> version;
|
||||
|
||||
@@ -41,10 +39,8 @@ struct ANCS : BigYAML
|
||||
atUint32 idx;
|
||||
std::string name;
|
||||
UniqueID32 cmdl;
|
||||
UniqueID32 _cskrOld;
|
||||
UniqueID32 _cinfOld;
|
||||
AuxiliaryID32 cskr = _S("skin");
|
||||
AuxiliaryID32 cinf = {_S("layout"), _S("skin")};
|
||||
UniqueID32 cskr;
|
||||
UniqueID32 cinf;
|
||||
|
||||
struct Animation : BigYAML
|
||||
{
|
||||
@@ -90,8 +86,7 @@ struct ANCS : BigYAML
|
||||
std::vector<Effect> effects;
|
||||
|
||||
UniqueID32 cmdlOverlay;
|
||||
UniqueID32 _cskrOverlayOld;
|
||||
AuxiliaryID32 cskrOverlay = _S("skin");
|
||||
UniqueID32 cskrOverlay;
|
||||
|
||||
std::vector<atUint32> animIdxs;
|
||||
|
||||
@@ -113,8 +108,6 @@ struct ANCS : BigYAML
|
||||
{
|
||||
DECL_YAML
|
||||
Delete expl;
|
||||
const UniqueID32& m_ancsId;
|
||||
AnimationSet(const UniqueID32& ancsId) : m_ancsId(ancsId), defaultTransition(ancsId) {}
|
||||
|
||||
using MP1AnimationSet = DNAMP1::ANCS::AnimationSet;
|
||||
|
||||
@@ -204,11 +197,11 @@ struct ANCS : BigYAML
|
||||
DNAANCS::CharacterResInfo<UniqueID32>& chOut = out.back();
|
||||
chOut.name = ci.name;
|
||||
chOut.cmdl = ci.cmdl;
|
||||
chOut.cskr = ci._cskrOld;
|
||||
chOut.cinf = ci._cinfOld;
|
||||
chOut.cskr = ci.cskr;
|
||||
chOut.cinf = ci.cinf;
|
||||
|
||||
if (ci.cmdlOverlay)
|
||||
chOut.overlays.emplace_back(FOURCC('OVER'), std::make_pair(ci.cmdlOverlay, ci._cskrOverlayOld));
|
||||
chOut.overlays.emplace_back(FOURCC('OVER'), std::make_pair(ci.cmdlOverlay, ci.cskrOverlay));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,6 +210,11 @@ struct ANCS : BigYAML
|
||||
out.clear();
|
||||
for (const DNAMP1::ANCS::AnimationSet::Animation& ai : animationSet.animations)
|
||||
ai.metaAnim.m_anim->gatherPrimitives(out);
|
||||
for (const DNAMP1::ANCS::AnimationSet::Transition& ti : animationSet.transitions)
|
||||
if (ti.metaTrans.m_trans)
|
||||
ti.metaTrans.m_trans->gatherPrimitives(out);
|
||||
if (animationSet.defaultTransition.m_trans)
|
||||
animationSet.defaultTransition.m_trans->gatherPrimitives(out);
|
||||
}
|
||||
|
||||
static bool Extract(const SpecBase& dataSpec,
|
||||
@@ -237,7 +235,7 @@ struct ANCS : BigYAML
|
||||
yamlType == hecl::ProjectPath::Type::None ||
|
||||
blendType == hecl::ProjectPath::Type::None)
|
||||
{
|
||||
ANCS ancs(entry.id);
|
||||
ANCS ancs;
|
||||
ancs.read(rs);
|
||||
|
||||
if (force || yamlType == hecl::ProjectPath::Type::None)
|
||||
|
||||
@@ -7,17 +7,17 @@ namespace DNAMP2
|
||||
|
||||
using ANIMOutStream = hecl::BlenderConnection::PyOutStream::ANIMOutStream;
|
||||
|
||||
void ANIM::IANIM::sendANIMToBlender(hecl::BlenderConnection::PyOutStream& os, const CINF& cinf) const
|
||||
void ANIM::IANIM::sendANIMToBlender(hecl::BlenderConnection::PyOutStream& os, const DNAANIM::RigInverter<CINF>& rig) const
|
||||
{
|
||||
os.format("act.hecl_fps = round(%f)\n", (1.0f / mainInterval));
|
||||
|
||||
auto kit = chanKeys.begin();
|
||||
for (const std::pair<atUint32, std::tuple<bool,bool,bool>>& bone : bones)
|
||||
{
|
||||
const std::string* bName = cinf.getBoneNameFromId(bone.first);
|
||||
const std::string* bName = rig.getCINF().getBoneNameFromId(bone.first);
|
||||
if (!bName)
|
||||
continue;
|
||||
|
||||
|
||||
os.format("bone_string = '%s'\n", bName->c_str());
|
||||
os << "action_group = act.groups.new(bone_string)\n"
|
||||
"\n";
|
||||
@@ -31,9 +31,9 @@ void ANIM::IANIM::sendANIMToBlender(hecl::BlenderConnection::PyOutStream& os, co
|
||||
"\n";
|
||||
|
||||
if (std::get<1>(bone.second))
|
||||
os << "bone_trans_head = (0.0,0.0,0.0)\n"
|
||||
"if arm_obj.data.bones[bone_string].parent is not None:\n"
|
||||
" bone_trans_head = Vector(arm_obj.data.bones[bone_string].head_local) - Vector(arm_obj.data.bones[bone_string].parent.head_local)\n"
|
||||
os << "#bone_trans_head = (0.0,0.0,0.0)\n"
|
||||
"#if arm_obj.data.bones[bone_string].parent is not None:\n"
|
||||
"# bone_trans_head = Vector(arm_obj.data.bones[bone_string].head_local) - Vector(arm_obj.data.bones[bone_string].parent.head_local)\n"
|
||||
"transCurves = []\n"
|
||||
"transCurves.append(act.fcurves.new('pose.bones[\"'+bone_string+'\"].location', index=0, action_group=bone_string))\n"
|
||||
"transCurves.append(act.fcurves.new('pose.bones[\"'+bone_string+'\"].location', index=1, action_group=bone_string))\n"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "BlenderConnection.hpp"
|
||||
#include "DNAMP2.hpp"
|
||||
#include "../DNACommon/ANIM.hpp"
|
||||
#include "../DNACommon/RigInverter.hpp"
|
||||
#include "CINF.hpp"
|
||||
|
||||
namespace DataSpec
|
||||
@@ -27,7 +28,7 @@ struct ANIM : BigDNA
|
||||
std::vector<std::vector<DNAANIM::Value>> chanKeys;
|
||||
float mainInterval = 0.0;
|
||||
|
||||
void sendANIMToBlender(hecl::BlenderConnection::PyOutStream&, const CINF&) const;
|
||||
void sendANIMToBlender(hecl::BlenderConnection::PyOutStream&, const DNAANIM::RigInverter<CINF>& rig) const;
|
||||
};
|
||||
|
||||
struct ANIM0 : IANIM
|
||||
@@ -210,9 +211,9 @@ struct ANIM : BigDNA
|
||||
return m_anim->binarySize(__isz + 4);
|
||||
}
|
||||
|
||||
void sendANIMToBlender(hecl::BlenderConnection::PyOutStream& os, const CINF& cinf, bool) const
|
||||
void sendANIMToBlender(hecl::BlenderConnection::PyOutStream& os, const DNAANIM::RigInverter<CINF>& rig, bool) const
|
||||
{
|
||||
m_anim->sendANIMToBlender(os, cinf);
|
||||
m_anim->sendANIMToBlender(os, rig);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -36,6 +36,18 @@ struct CINF : BigDNA
|
||||
Value<atUint32> boneId;
|
||||
};
|
||||
Vector<Name, DNA_COUNT(nameCount)> names;
|
||||
|
||||
atUint32 getInternalBoneIdxFromId(atUint32 id) const
|
||||
{
|
||||
atUint32 idx = 0;
|
||||
for (const Bone& b : bones)
|
||||
{
|
||||
if (b.id == id)
|
||||
return idx;
|
||||
++idx;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
atUint32 getBoneIdxFromId(atUint32 id) const
|
||||
{
|
||||
|
||||
@@ -198,13 +198,13 @@ void PAKBridge::addCMDLRigPairs(PAKRouter<PAKBridge>& pakRouter,
|
||||
if (entry.second->type == FOURCC('ANCS'))
|
||||
{
|
||||
PAKEntryReadStream rs = entry.second->beginReadStream(m_node);
|
||||
ANCS ancs(entry.first);
|
||||
ANCS ancs;
|
||||
ancs.read(rs);
|
||||
for (const ANCS::CharacterSet::CharacterInfo& ci : ancs.characterSet.characters)
|
||||
{
|
||||
addTo[ci.cmdl] = std::make_pair(ci.cskr.getBaseId(), ci.cinf.getBaseId());
|
||||
addTo[ci.cmdl] = std::make_pair(ci.cskr, ci.cinf);
|
||||
if (ci.cmdlOverlay)
|
||||
addTo[ci.cmdlOverlay] = std::make_pair(ci.cskrOverlay.getBaseId(), ci.cinf.getBaseId());
|
||||
addTo[ci.cmdlOverlay] = std::make_pair(ci.cskrOverlay, ci.cinf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user