From 28b9cd9e3fbf2242fab94dba2bee389d6c238eec Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 5 Apr 2016 15:44:07 -1000 Subject: [PATCH] AuxiliaryID32 implemented for sub-resources --- DataSpec/DNACommon/ANCS.hpp | 14 + DataSpec/DNACommon/DNACommon.cpp | 1 + DataSpec/DNACommon/DNACommon.hpp | 66 +++++ DataSpec/DNAMP1/ANCS.cpp | 113 ++++++-- DataSpec/DNAMP1/ANCS.hpp | 260 ++++++++++++++++-- DataSpec/DNAMP1/DNAMP1.cpp | 12 +- DataSpec/DNAMP1/ScriptObjects/Parameters.cpp | 4 +- DataSpec/DNAMP1/ScriptObjects/Parameters.hpp | 4 +- DataSpec/DNAMP2/ANCS.cpp | 66 ++++- DataSpec/DNAMP2/ANCS.hpp | 13 +- DataSpec/DNAMP2/DNAMP2.cpp | 6 +- Editor/ProjectResourceFactoryBase.cpp | 5 +- Editor/ProjectResourceFactoryBase.hpp | 2 +- Editor/ViewManager.cpp | 2 + Runtime/Character/CMakeLists.txt | 1 - Runtime/Graphics/CMakeLists.txt | 1 + .../{Character => Graphics}/CSkinRules.cpp | 0 .../{Character => Graphics}/CSkinRules.hpp | 0 hecl | 2 +- 19 files changed, 497 insertions(+), 75 deletions(-) rename Runtime/{Character => Graphics}/CSkinRules.cpp (100%) rename Runtime/{Character => Graphics}/CSkinRules.hpp (100%) diff --git a/DataSpec/DNACommon/ANCS.hpp b/DataSpec/DNACommon/ANCS.hpp index 03d36e5d9..e45dd281a 100644 --- a/DataSpec/DNACommon/ANCS.hpp +++ b/DataSpec/DNACommon/ANCS.hpp @@ -32,6 +32,20 @@ struct AnimationResInfo bool additive; }; +static void WriteOutAnimId(athena::io::YAMLDocWriter& __dna_docout, + const UniqueID32& ancsId, + const std::string& animName) +{ + __dna_docout.enterSubRecord("animId"); + hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(ancsId); + if (path) + { + path = path.getWithExtension(_S(".blend")); + __dna_docout.writeString(nullptr, path.getRelativePathUTF8() + _S('|') + animName); + } + __dna_docout.leaveSubRecord(); +} + template bool ReadANCSToBlender(hecl::BlenderConnection& conn, const ANCSDNA& ancs, diff --git a/DataSpec/DNACommon/DNACommon.cpp b/DataSpec/DNACommon/DNACommon.cpp index 1df58b420..d60854f82 100644 --- a/DataSpec/DNACommon/DNACommon.cpp +++ b/DataSpec/DNACommon/DNACommon.cpp @@ -8,5 +8,6 @@ logvisor::Module LogDNACommon("urde::DNACommon"); SpecBase* g_curSpec = nullptr; PAKRouterBase* g_PakRouter = nullptr; hecl::Database::Project* UniqueIDBridge::s_Project = nullptr; +UniqueID32 UniqueID32::kInvalidId; } diff --git a/DataSpec/DNACommon/DNACommon.hpp b/DataSpec/DNACommon/DNACommon.hpp index 1a5d761a3..6b840a61c 100644 --- a/DataSpec/DNACommon/DNACommon.hpp +++ b/DataSpec/DNACommon/DNACommon.hpp @@ -116,8 +116,10 @@ public: /** PAK 32-bit Unique ID */ class UniqueID32 : public BigYAML { +protected: uint32_t m_id = 0xffffffff; public: + static UniqueID32 kInvalidId; Delete expl; operator bool() const {return m_id != 0xffffffff && m_id != 0;} void read(athena::io::IStreamReader& reader) @@ -176,6 +178,70 @@ public: static constexpr size_t BinarySize() {return 4;} }; +class AuxiliaryID32 : public UniqueID32 +{ + const hecl::SystemChar* m_auxStr; + const hecl::SystemChar* m_addExtension; + UniqueID32 m_baseId; +public: + AuxiliaryID32(const hecl::SystemChar* auxStr, + const hecl::SystemChar* addExtension=nullptr) + : m_auxStr(auxStr), m_addExtension(addExtension) {} + + AuxiliaryID32& operator=(const hecl::ProjectPath& path) + { + m_id = path.ensureAuxInfo(m_auxStr).hash().val32(); + return *this; + } + + AuxiliaryID32& operator=(const UniqueID32& id) + { + m_baseId = id; + hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(id); + if (path) + { + if (m_addExtension) + path = path.getWithExtension(m_addExtension); + *this = path; + } + return *this; + } + + void read(athena::io::IStreamReader& reader) + { + m_id = reader.readUint32Big(); + m_baseId = *this; + } + + void write(athena::io::IStreamWriter& writer) const + { + writer.writeUint32Big(m_id); + } + + void read(athena::io::YAMLDocReader& reader) + { + hecl::ProjectPath readPath = UniqueIDBridge::MakePathFromString(reader.readString(nullptr)); + *this = readPath.ensureAuxInfo(m_auxStr); + } + + void write(athena::io::YAMLDocWriter& writer) const + { + if (!operator bool()) + return; + hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(*this); + if (!path) + path = UniqueIDBridge::TranslatePakIdToPath(m_baseId); + if (!path) + return; + if (m_addExtension) + path = path.getWithExtension(m_addExtension); + hecl::SystemUTF8View ufx8AuxStr(m_auxStr); + writer.writeString(nullptr, path.getRelativePathUTF8() + '|' + ufx8AuxStr); + } + + const UniqueID32& getBaseId() const {return m_baseId;} +}; + /** PAK 64-bit Unique ID */ class UniqueID64 : public BigYAML { diff --git a/DataSpec/DNAMP1/ANCS.cpp b/DataSpec/DNAMP1/ANCS.cpp index 80a8098fb..a50830968 100644 --- a/DataSpec/DNAMP1/ANCS.cpp +++ b/DataSpec/DNAMP1/ANCS.cpp @@ -407,8 +407,8 @@ void ANCS::CharacterSet::CharacterInfo::write(athena::io::IStreamWriter& writer) writer.writeString(name); cmdl.write(writer); - cskr.write(writer); - cinf.write(writer); + cskr.UniqueID32::write(writer); + cinf.UniqueID32::write(writer); writer.writeUint32Big(animations.size()); writer.enumerate(animations); @@ -447,7 +447,7 @@ void ANCS::CharacterSet::CharacterInfo::write(athena::io::IStreamWriter& writer) if (sectionCount > 3) { cmdlOverlay.write(writer); - cskrOverlay.write(writer); + cskrOverlay.UniqueID32::write(writer); } if (sectionCount > 4) @@ -648,23 +648,23 @@ void ANCS::AnimationSet::MetaAnimFactory::read(athena::io::IStreamReader& reader switch (type) { case IMetaAnim::Type::Primitive: - m_anim.reset(new struct MetaAnimPrimitive); + m_anim.reset(new struct MetaAnimPrimitive(m_ancsId)); m_anim->read(reader); break; case IMetaAnim::Type::Blend: - m_anim.reset(new struct MetaAnimBlend); + m_anim.reset(new struct MetaAnimBlend(m_ancsId)); m_anim->read(reader); break; case IMetaAnim::Type::PhaseBlend: - m_anim.reset(new struct MetaAnimPhaseBlend); + m_anim.reset(new struct MetaAnimPhaseBlend(m_ancsId)); m_anim->read(reader); break; case IMetaAnim::Type::Random: - m_anim.reset(new struct MetaAnimRandom); + m_anim.reset(new struct MetaAnimRandom(m_ancsId)); m_anim->read(reader); break; case IMetaAnim::Type::Sequence: - m_anim.reset(new struct MetaAnimSequence); + m_anim.reset(new struct MetaAnimSequence(m_ancsId)); m_anim->read(reader); break; default: @@ -694,27 +694,27 @@ void ANCS::AnimationSet::MetaAnimFactory::read(athena::io::YAMLDocReader& reader std::transform(type.begin(), type.end(), type.begin(), tolower); if (!type.compare("primitive")) { - m_anim.reset(new struct MetaAnimPrimitive); + m_anim.reset(new struct MetaAnimPrimitive(m_ancsId)); m_anim->read(reader); } else if (!type.compare("blend")) { - m_anim.reset(new struct MetaAnimBlend); + m_anim.reset(new struct MetaAnimBlend(m_ancsId)); m_anim->read(reader); } else if (!type.compare("phaseblend")) { - m_anim.reset(new struct MetaAnimPhaseBlend); + m_anim.reset(new struct MetaAnimPhaseBlend(m_ancsId)); m_anim->read(reader); } else if (!type.compare("random")) { - m_anim.reset(new struct MetaAnimRandom); + m_anim.reset(new struct MetaAnimRandom(m_ancsId)); m_anim->read(reader); } else if (!type.compare("sequence")) { - m_anim.reset(new struct MetaAnimSequence); + m_anim.reset(new struct MetaAnimSequence(m_ancsId)); m_anim->read(reader); } else @@ -743,15 +743,15 @@ void ANCS::AnimationSet::MetaTransFactory::read(athena::io::IStreamReader& reade switch (type) { case IMetaTrans::Type::MetaAnim: - m_trans.reset(new struct MetaTransMetaAnim); + m_trans.reset(new struct MetaTransMetaAnim(m_ancsId)); m_trans->read(reader); break; case IMetaTrans::Type::Trans: - m_trans.reset(new struct MetaTransTrans); + m_trans.reset(new struct MetaTransTrans(m_ancsId)); m_trans->read(reader); break; case IMetaTrans::Type::PhaseTrans: - m_trans.reset(new struct MetaTransPhaseTrans); + m_trans.reset(new struct MetaTransPhaseTrans(m_ancsId)); m_trans->read(reader); break; case IMetaTrans::Type::NoTrans: @@ -785,17 +785,17 @@ void ANCS::AnimationSet::MetaTransFactory::read(athena::io::YAMLDocReader& reade std::transform(type.begin(), type.end(), type.begin(), tolower); if (!type.compare("metaanim")) { - m_trans.reset(new struct MetaTransMetaAnim); + m_trans.reset(new struct MetaTransMetaAnim(m_ancsId)); m_trans->read(reader); } else if (!type.compare("trans")) { - m_trans.reset(new struct MetaTransTrans); + m_trans.reset(new struct MetaTransTrans(m_ancsId)); m_trans->read(reader); } else if (!type.compare("phasetrans")) { - m_trans.reset(new struct MetaTransPhaseTrans); + m_trans.reset(new struct MetaTransPhaseTrans(m_ancsId)); m_trans->read(reader); } else @@ -826,10 +826,23 @@ void ANCS::AnimationSet::read(athena::io::IStreamReader& reader) atUint16 sectionCount = reader.readUint16Big(); atUint32 animationCount = reader.readUint32Big(); - reader.enumerate(animations, animationCount); + animations.clear(); + animations.reserve(animationCount); + for (size_t i=0 ; i 2) { - atUint32 halfTransitionCount = reader.readUint32Big(); - reader.enumerate(halfTransitions, halfTransitionCount); + atUint32 halfTransitionCount = reader.readUint32Big(); + halfTransitions.reserve(halfTransitionCount); + for (size_t i=0 ; i 2) { - reader.enumerate("halfTransitions", halfTransitions); + size_t halfTransitionCount; + if (reader.enterSubVector("halfTransitions", halfTransitionCount)) + { + halfTransitions.reserve(halfTransitionCount); + for (size_t i=0 ; i 3) { reader.enumerate("animResources", animResources); } +#endif } void ANCS::AnimationSet::write(athena::io::YAMLDocWriter& writer) const @@ -1000,10 +1059,12 @@ void ANCS::AnimationSet::write(athena::io::YAMLDocWriter& writer) const writer.enumerate("halfTransitions", halfTransitions); } +#if 0 if (sectionCount > 3) { writer.enumerate("animResources", animResources); } +#endif } const char* ANCS::AnimationSet::DNAType() diff --git a/DataSpec/DNAMP1/ANCS.hpp b/DataSpec/DNAMP1/ANCS.hpp index 51d3f80d4..b877e14f4 100644 --- a/DataSpec/DNAMP1/ANCS.hpp +++ b/DataSpec/DNAMP1/ANCS.hpp @@ -22,6 +22,8 @@ struct ANCS : BigYAML using CSKRType = CSKR; using ANIMType = ANIM; + ANCS(const UniqueID32& ancsId) : animationSet(ancsId) {} + DECL_YAML Value version; @@ -31,15 +33,15 @@ struct ANCS : BigYAML Value version; Value characterCount; struct CharacterInfo : BigYAML - { + { DECL_YAML Delete expl; atUint32 idx; std::string name; UniqueID32 cmdl; - UniqueID32 cskr; - UniqueID32 cinf; + AuxiliaryID32 cskr = _S("skin"); + AuxiliaryID32 cinf = {_S("layout"), _S(".blend")}; struct Animation : BigYAML { @@ -143,7 +145,7 @@ struct ANCS : BigYAML std::vector effects; UniqueID32 cmdlOverlay; - UniqueID32 cskrOverlay; + AuxiliaryID32 cskrOverlay = _S("skin"); std::vector animIdxs; }; @@ -154,6 +156,9 @@ struct ANCS : BigYAML { DECL_YAML Delete expl; + const UniqueID32& m_ancsId; + AnimationSet(const UniqueID32& ancsId) + : m_ancsId(ancsId), defaultTransition(ancsId) {} struct IMetaAnim : BigYAML { @@ -168,26 +173,98 @@ struct ANCS : BigYAML Sequence = 4 } m_type; const char* m_typeStr; - IMetaAnim(Type type, const char* typeStr) - : m_type(type), m_typeStr(typeStr) {} + const UniqueID32& m_ancsId; + IMetaAnim(Type type, const char* typeStr, const UniqueID32& ancsId) + : m_type(type), m_typeStr(typeStr), m_ancsId(ancsId) {} virtual void gatherPrimitives(std::map>& out)=0; }; struct MetaAnimFactory : BigYAML { DECL_YAML Delete expl; + const UniqueID32& m_ancsId; std::unique_ptr m_anim; + MetaAnimFactory(const UniqueID32& ancsId) : m_ancsId(ancsId) {} }; struct MetaAnimPrimitive : IMetaAnim { - MetaAnimPrimitive() : IMetaAnim(Type::Primitive, "Primitive") {} - DECL_YAML + MetaAnimPrimitive(const UniqueID32& ancsId) : IMetaAnim(Type::Primitive, "Primitive", ancsId) {} + + Delete _d; UniqueID32 animId; Value animIdx; String<-1> animName; Value unk1; Value unk2; + void read(athena::io::IStreamReader& __dna_reader) + { + /* animId */ + animId.read(__dna_reader); + /* animIdx */ + animIdx = __dna_reader.readUint32Big(); + /* animName */ + animName = __dna_reader.readString(-1); + /* unk1 */ + unk1 = __dna_reader.readFloatBig(); + /* unk2 */ + unk2 = __dna_reader.readUint32Big(); + } + + void write(athena::io::IStreamWriter& __dna_writer) const + { + /* animId */ + animId.write(__dna_writer); + /* animIdx */ + __dna_writer.writeUint32Big(animIdx); + /* animName */ + __dna_writer.writeString(animName, -1); + /* unk1 */ + __dna_writer.writeFloatBig(unk1); + /* unk2 */ + __dna_writer.writeUint32Big(unk2); + } + + void read(athena::io::YAMLDocReader& __dna_docin) + { + /* animId */ + __dna_docin.enumerate("animId", animId); + /* animIdx */ + animIdx = __dna_docin.readUint32("animIdx"); + /* animName */ + animName = __dna_docin.readString("animName"); + /* unk1 */ + unk1 = __dna_docin.readFloat("unk1"); + /* unk2 */ + unk2 = __dna_docin.readUint32("unk2"); + } + + void write(athena::io::YAMLDocWriter& __dna_docout) const + { + /* animId */ + DNAANCS::WriteOutAnimId(__dna_docout, m_ancsId, animName); + /* animIdx */ + __dna_docout.writeUint32("animIdx", animIdx); + /* animName */ + __dna_docout.writeString("animName", animName); + /* unk1 */ + __dna_docout.writeFloat("unk1", unk1); + /* unk2 */ + __dna_docout.writeUint32("unk2", unk2); + } + + static const char* DNAType() + { + return "DataSpec::DNAMP1::ANCS::AnimationSet::MetaAnimPrimitive"; + } + + size_t binarySize(size_t __isz) const + { + __isz = animId.binarySize(__isz); + __isz += animName.size() + 1; + return __isz + 12; + } + void gatherPrimitives(std::map>& out) { out[animIdx] = {animName, animId, UniqueID32(), false}; @@ -195,7 +272,8 @@ struct ANCS : BigYAML }; struct MetaAnimBlend : IMetaAnim { - MetaAnimBlend() : IMetaAnim(Type::Blend, "Blend") {} + MetaAnimBlend(const UniqueID32& ancsId) + : IMetaAnim(Type::Blend, "Blend", ancsId), animA(ancsId), animB(ancsId) {} DECL_YAML MetaAnimFactory animA; MetaAnimFactory animB; @@ -210,7 +288,8 @@ struct ANCS : BigYAML }; struct MetaAnimPhaseBlend : IMetaAnim { - MetaAnimPhaseBlend() : IMetaAnim(Type::PhaseBlend, "PhaseBlend") {} + MetaAnimPhaseBlend(const UniqueID32& ancsId) + : IMetaAnim(Type::PhaseBlend, "PhaseBlend", ancsId), animA(ancsId), animB(ancsId) {} DECL_YAML MetaAnimFactory animA; MetaAnimFactory animB; @@ -225,17 +304,77 @@ struct ANCS : BigYAML }; struct MetaAnimRandom : IMetaAnim { - MetaAnimRandom() : IMetaAnim(Type::Random, "Random") {} - DECL_YAML + MetaAnimRandom(const UniqueID32& ancsId) : IMetaAnim(Type::Random, "Random", ancsId) {} + Delete _d; Value animCount; struct Child : BigYAML { DECL_YAML MetaAnimFactory anim; Value probability; + Child(const UniqueID32& ancsId) : anim(ancsId) {} }; Vector children; + void read(athena::io::IStreamReader& __dna_reader) + { + /* animCount */ + animCount = __dna_reader.readUint32Big(); + /* children */ + children.clear(); + children.reserve(animCount); + for (size_t i=0 ; i>& out) { for (const auto& child : children) @@ -244,11 +383,70 @@ struct ANCS : BigYAML }; struct MetaAnimSequence : IMetaAnim { - MetaAnimSequence() : IMetaAnim(Type::Sequence, "Sequence") {} - DECL_YAML + MetaAnimSequence(const UniqueID32& ancsId) : IMetaAnim(Type::Sequence, "Sequence", ancsId) {} + Delete _d; Value animCount; Vector children; + void read(athena::io::IStreamReader& __dna_reader) + { + /* animCount */ + animCount = __dna_reader.readUint32Big(); + /* children */ + children.clear(); + children.reserve(animCount); + for (size_t i=0 ; i>& out) { for (const auto& child : children) @@ -261,6 +459,7 @@ struct ANCS : BigYAML DECL_YAML String<-1> name; MetaAnimFactory metaAnim; + Animation(const UniqueID32& ancsId) : metaAnim(ancsId) {} }; std::vector animations; @@ -276,24 +475,29 @@ struct ANCS : BigYAML NoTrans = 3, } m_type; const char* m_typeStr; - IMetaTrans(Type type, const char* typeStr) - : m_type(type), m_typeStr(typeStr) {} + const UniqueID32& m_ancsId; + IMetaTrans(Type type, const char* typeStr, const UniqueID32& ancsId) + : m_type(type), m_typeStr(typeStr), m_ancsId(ancsId) {} }; struct MetaTransFactory : BigYAML { DECL_YAML Delete expl; + const UniqueID32& m_ancsId; std::unique_ptr m_trans; + MetaTransFactory(const UniqueID32& ancsId) : m_ancsId(ancsId) {} }; struct MetaTransMetaAnim : IMetaTrans { - MetaTransMetaAnim() : IMetaTrans(Type::MetaAnim, "MetaAnim") {} + MetaTransMetaAnim(const UniqueID32& ancsId) + : IMetaTrans(Type::MetaAnim, "MetaAnim", ancsId), anim(ancsId) {} DECL_YAML MetaAnimFactory anim; }; struct MetaTransTrans : IMetaTrans { - MetaTransTrans() : IMetaTrans(Type::Trans, "Trans") {} + MetaTransTrans(const UniqueID32& ancsId) + : IMetaTrans(Type::Trans, "Trans", ancsId) {} DECL_YAML Value time; Value unk1; @@ -303,7 +507,8 @@ struct ANCS : BigYAML }; struct MetaTransPhaseTrans : IMetaTrans { - MetaTransPhaseTrans() : IMetaTrans(Type::PhaseTrans, "PhaseTrans") {} + MetaTransPhaseTrans(const UniqueID32& ancsId) + : IMetaTrans(Type::PhaseTrans, "PhaseTrans", ancsId) {} DECL_YAML Value time; Value unk1; @@ -319,6 +524,7 @@ struct ANCS : BigYAML Value animIdxA; Value animIdxB; MetaTransFactory metaTrans; + Transition(const UniqueID32& ancsId) : metaTrans(ancsId) {} }; std::vector transitions; MetaTransFactory defaultTransition; @@ -340,6 +546,7 @@ struct ANCS : BigYAML DECL_YAML Value animIdx; MetaTransFactory metaTrans; + HalfTransition(const UniqueID32& ancsId) : metaTrans(ancsId) {} }; std::vector halfTransitions; @@ -388,6 +595,16 @@ struct ANCS : BigYAML } } + void fixupPaths(const UniqueID32& ancsId) + { + for (CharacterSet::CharacterInfo& character : characterSet.characters) + { + character.cskr = character.cmdl; + character.cinf = ancsId; + character.cskrOverlay = character.cmdlOverlay; + } + } + static bool Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl::ProjectPath& outPath, @@ -406,8 +623,9 @@ struct ANCS : BigYAML yamlType == hecl::ProjectPath::Type::None || blendType == hecl::ProjectPath::Type::None) { - ANCS ancs; + ANCS ancs(entry.id); ancs.read(rs); + ancs.fixupPaths(entry.id); if (force || yamlType == hecl::ProjectPath::Type::None) { @@ -441,7 +659,7 @@ struct ANCS : BigYAML if (!BigYAML::ValidateFromYAMLFile(yamlReader)) Log.report(logvisor::Fatal, _S("'%s' is not urde::DNAMP1::ANCS type"), yamlPath.getRelativePath().c_str()); - ANCS ancs; + ANCS ancs(UniqueID32::kInvalidId); ancs.read(yamlReader); diff --git a/DataSpec/DNAMP1/DNAMP1.cpp b/DataSpec/DNAMP1/DNAMP1.cpp index 091b060c3..e897a0d59 100644 --- a/DataSpec/DNAMP1/DNAMP1.cpp +++ b/DataSpec/DNAMP1/DNAMP1.cpp @@ -227,22 +227,22 @@ void PAKBridge::addCMDLRigPairs(PAKRouter& pakRouter, if (entry.second->type == FOURCC('ANCS')) { PAKEntryReadStream rs = entry.second->beginReadStream(m_node); - ANCS ancs; + ANCS ancs(entry.first); ancs.read(rs); for (const ANCS::CharacterSet::CharacterInfo& ci : ancs.characterSet.characters) { - addTo[ci.cmdl] = std::make_pair(ci.cskr, ci.cinf); + addTo[ci.cmdl] = std::make_pair(ci.cskr.getBaseId(), ci.cinf.getBaseId()); PAK::Entry* cmdlEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cmdl); - PAK::Entry* cskrEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cskr); - PAK::Entry* cinfEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cinf); + PAK::Entry* cskrEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cskr.getBaseId()); + PAK::Entry* cinfEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cinf.getBaseId()); cmdlEnt->name = hecl::Format("ANCS_%08X_%s_model", entry.first.toUint32(), ci.name.c_str()); cskrEnt->name = hecl::Format("ANCS_%08X_%s_skin", entry.first.toUint32(), ci.name.c_str()); cinfEnt->name = hecl::Format("ANCS_%08X_%s_skel", entry.first.toUint32(), ci.name.c_str()); if (ci.cmdlOverlay && ci.cskrOverlay) { - addTo[ci.cmdlOverlay] = std::make_pair(ci.cskrOverlay, ci.cinf); + addTo[ci.cmdlOverlay] = std::make_pair(ci.cskrOverlay.getBaseId(), ci.cinf.getBaseId()); PAK::Entry* cmdlEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cmdlOverlay); - PAK::Entry* cskrEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cskrOverlay); + PAK::Entry* cskrEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cskrOverlay.getBaseId()); cmdlEnt->name = hecl::Format("ANCS_%08X_%s_overmodel", entry.first.toUint32(), ci.name.c_str()); cskrEnt->name = hecl::Format("ANCS_%08X_%s_overskin", entry.first.toUint32(), ci.name.c_str()); } diff --git a/DataSpec/DNAMP1/ScriptObjects/Parameters.cpp b/DataSpec/DNAMP1/ScriptObjects/Parameters.cpp index 0456bb115..9b6a9b2bf 100644 --- a/DataSpec/DNAMP1/ScriptObjects/Parameters.cpp +++ b/DataSpec/DNAMP1/ScriptObjects/Parameters.cpp @@ -12,12 +12,12 @@ UniqueID32 AnimationParameters::getCINF(PAKRouter& pakRouter) const return UniqueID32(); const nod::Node* node; const PAK::Entry* ancsEnt = pakRouter.lookupEntry(animationCharacterSet, &node); - ANCS ancs; + ANCS ancs(ancsEnt->id); { PAKEntryReadStream rs = ancsEnt->beginReadStream(*node); ancs.read(rs); } - return ancs.characterSet.characters.at(character).cinf; + return ancs.characterSet.characters.at(character).cinf.getBaseId(); } } diff --git a/DataSpec/DNAMP1/ScriptObjects/Parameters.hpp b/DataSpec/DNAMP1/ScriptObjects/Parameters.hpp index 8f449209e..622d26b00 100644 --- a/DataSpec/DNAMP1/ScriptObjects/Parameters.hpp +++ b/DataSpec/DNAMP1/ScriptObjects/Parameters.hpp @@ -354,9 +354,9 @@ struct ActorParameters : BigYAML LightParameters lightParameters; ScannableParameters scannableParameters; UniqueID32 xrayModel; - UniqueID32 xraySkin; + AuxiliaryID32 xraySkin = _S("skin"); UniqueID32 thermalModel; - UniqueID32 thermalSkin; + AuxiliaryID32 thermalSkin = _S("skin"); Value unknown1; Value unknown2; Value unknown3; diff --git a/DataSpec/DNAMP2/ANCS.cpp b/DataSpec/DNAMP2/ANCS.cpp index c26fd175e..c2d3eda89 100644 --- a/DataSpec/DNAMP2/ANCS.cpp +++ b/DataSpec/DNAMP2/ANCS.cpp @@ -381,10 +381,23 @@ void ANCS::AnimationSet::read(athena::io::IStreamReader& reader) atUint16 sectionCount = reader.readUint16Big(); atUint32 animationCount = reader.readUint32Big(); - reader.enumerate(animations, animationCount); + animations.clear(); + animations.reserve(animationCount); + for (atUint32 i=0 ; i 2) { - atUint32 halfTransitionCount = reader.readUint32Big(); - reader.enumerate(halfTransitions, halfTransitionCount); + atUint32 halfTransitionCount = reader.readUint32Big(); + halfTransitions.clear(); + halfTransitions.reserve(halfTransitionCount); + for (atUint32 i=0 ; i 2) { - reader.enumerate("halfTransitions", halfTransitions); + size_t halfTransitionCount; + reader.enterSubVector("halfTransitions", halfTransitionCount); + halfTransitions.reserve(halfTransitionCount); + for (size_t i=0 ; i version; @@ -39,8 +41,8 @@ struct ANCS : BigYAML atUint32 idx; std::string name; UniqueID32 cmdl; - UniqueID32 cskr; - UniqueID32 cinf; + AuxiliaryID32 cskr = _S("skin"); + AuxiliaryID32 cinf = {_S("layout"), _S("skin")}; struct Animation : BigYAML { @@ -86,7 +88,7 @@ struct ANCS : BigYAML std::vector effects; UniqueID32 cmdlOverlay; - UniqueID32 cskrOverlay; + AuxiliaryID32 cskrOverlay = _S("skin"); std::vector animIdxs; @@ -108,6 +110,9 @@ 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; std::vector animations; @@ -229,7 +234,7 @@ struct ANCS : BigYAML yamlType == hecl::ProjectPath::Type::None || blendType == hecl::ProjectPath::Type::None) { - ANCS ancs; + ANCS ancs(entry.id); ancs.read(rs); if (force || yamlType == hecl::ProjectPath::Type::None) diff --git a/DataSpec/DNAMP2/DNAMP2.cpp b/DataSpec/DNAMP2/DNAMP2.cpp index 495ab1384..d67e72461 100644 --- a/DataSpec/DNAMP2/DNAMP2.cpp +++ b/DataSpec/DNAMP2/DNAMP2.cpp @@ -198,13 +198,13 @@ void PAKBridge::addCMDLRigPairs(PAKRouter& pakRouter, if (entry.second->type == FOURCC('ANCS')) { PAKEntryReadStream rs = entry.second->beginReadStream(m_node); - ANCS ancs; + ANCS ancs(entry.first); ancs.read(rs); for (const ANCS::CharacterSet::CharacterInfo& ci : ancs.characterSet.characters) { - addTo[ci.cmdl] = std::make_pair(ci.cskr, ci.cinf); + addTo[ci.cmdl] = std::make_pair(ci.cskr.getBaseId(), ci.cinf.getBaseId()); if (ci.cmdlOverlay) - addTo[ci.cmdlOverlay] = std::make_pair(ci.cskrOverlay, ci.cinf); + addTo[ci.cmdlOverlay] = std::make_pair(ci.cskrOverlay.getBaseId(), ci.cinf.getBaseId()); } } } diff --git a/Editor/ProjectResourceFactoryBase.cpp b/Editor/ProjectResourceFactoryBase.cpp index 39aaa08e5..c8ae29700 100644 --- a/Editor/ProjectResourceFactoryBase.cpp +++ b/Editor/ProjectResourceFactoryBase.cpp @@ -292,7 +292,10 @@ hecl::ProjectPath ProjectResourceFactoryBase::GetCookedPath(const hecl::ProjectP spec = m_cookSpec->overrideDataSpec(working, m_pcSpec, hecl::SharedBlenderToken); if (!spec) return {}; - return working.getCookedPath(*spec); + if (working.getAuxInfo().size()) + return working.getCookedPath(*spec).getWithExtension((_S('.') + working.getAuxInfo()).c_str()); + else + return working.getCookedPath(*spec); } bool ProjectResourceFactoryBase::SyncCook(const hecl::ProjectPath& working) diff --git a/Editor/ProjectResourceFactoryBase.hpp b/Editor/ProjectResourceFactoryBase.hpp index b66c2669e..98633c2ae 100644 --- a/Editor/ProjectResourceFactoryBase.hpp +++ b/Editor/ProjectResourceFactoryBase.hpp @@ -40,7 +40,7 @@ protected: ProjectResourceFactoryBase& m_parent; SObjectTag x0_tag; - IDvdRequest* x8_dvdReq = nullptr; + //IDvdRequest* x8_dvdReq = nullptr; IObj** xc_targetPtr = nullptr; std::unique_ptr x10_loadBuffer; u32 x14_resSize = 0; diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index bae77a148..543a09783 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -11,6 +11,7 @@ #include "Runtime/Particle/CSwooshDescription.hpp" #include "Runtime/Graphics/CModel.hpp" #include "Runtime/Graphics/CGraphics.hpp" +#include "Runtime/Graphics/CSkinRules.hpp" #include using YAMLNode = athena::io::YAMLNode; @@ -20,6 +21,7 @@ namespace urde void ViewManager::BuildTestPART(urde::IObjectStore& objStore) { + TToken m_modelTest = objStore.GetObj("MP1/SamusGun/CMDL_0EF58656.blend"); //m_modelTest = objStore.GetObj("CMDL_GameCube"); m_modelTest.Lock(); diff --git a/Runtime/Character/CMakeLists.txt b/Runtime/Character/CMakeLists.txt index fbe71ad74..a978ffaae 100644 --- a/Runtime/Character/CMakeLists.txt +++ b/Runtime/Character/CMakeLists.txt @@ -11,5 +11,4 @@ add_library(RuntimeCommonCharacter CTransitionDatabaseGame.hpp CHierarchyPoseBuilder.hpp CHierarchyPoseBuilder.cpp CPoseAsTransforms.hpp CPoseAsTransforms.cpp - CSkinRules.hpp CSkinRules.cpp CVirtualBone.hpp CVirtualBone.cpp) diff --git a/Runtime/Graphics/CMakeLists.txt b/Runtime/Graphics/CMakeLists.txt index 5f7449610..fcba1f816 100644 --- a/Runtime/Graphics/CMakeLists.txt +++ b/Runtime/Graphics/CMakeLists.txt @@ -20,5 +20,6 @@ add_library(RuntimeCommonGraphics CVertexMorphEffect.hpp CVertexMorphEffect.cpp CMoviePlayer.hpp CMoviePlayer.cpp CGraphicsPalette.hpp CGraphicsPalette.cpp + CSkinRules.hpp CSkinRules.cpp CGraphics.hpp CGraphics.cpp ${PLAT_SRCS}) diff --git a/Runtime/Character/CSkinRules.cpp b/Runtime/Graphics/CSkinRules.cpp similarity index 100% rename from Runtime/Character/CSkinRules.cpp rename to Runtime/Graphics/CSkinRules.cpp diff --git a/Runtime/Character/CSkinRules.hpp b/Runtime/Graphics/CSkinRules.hpp similarity index 100% rename from Runtime/Character/CSkinRules.hpp rename to Runtime/Graphics/CSkinRules.hpp diff --git a/hecl b/hecl index 97a5fb2af..de043503e 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 97a5fb2af2b16283af8c9bb619111a49d2869c7d +Subproject commit de043503e5d2312ccc10876b0ac3d5ebb91bb768