diff options
| author | Nicholas Estelami <NEstelami@users.noreply.github.com> | 2021-04-13 07:49:30 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-13 07:49:30 -0400 |
| commit | 420508d2d872e8653081d95a43bf2ad8f85d894c (patch) | |
| tree | 9019e0a87ad719c4a3b1e38c61e7b67feebfa63a /ZAPD/ZAnimation.cpp | |
| parent | 95bf5fc0080135f20f3ab17082f79b9e539e80a5 (diff) | |
Refactoring and various features added (#108)
* ZAPD prints out git hash
* Refactor: ZResource constructor sets parent always.
ZOverlay also no longer a ZResource, since it did not make much sense.
* Organized ZResource a bit
* A number of bug fixes, cleanup, and feature improvements.
* Prepping for legacy dlist disasm
* Fixed some merging issues. Fixed compilation issues with MSVC. Added in proper support for legacy display list disassembler. Refactored parts of ZFile.
* Merge with upstream
* Finished ZFile refactor, and other tidying.
* Fixed up merge issues
* Minor cleanup
* Got rid of libgfxd_win.a
* Fixed matching issue
* Fixed up a few bugs
* Fixed issue with exceptions
* Fixed up merge issues with ZPrerender, along with cleaning up some code
* Additional cleanup
* Fixed merge issues with ZMtx and fixed a bug with ZDisplayList
* Fixes based on PR feedback
* run clang-format (#7)
Signed-off-by: angie <angheloalf95@gmail.com>
* Fixed merge issues with Roz's PR
* Misc fixes
* Fixed MM bug, removed redundant file.
* Removed some commented out code
Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
Co-authored-by: Anghelo Carvajal <anghelo.carvajal.14@sansano.usm.cl>
Diffstat (limited to 'ZAPD/ZAnimation.cpp')
| -rw-r--r-- | ZAPD/ZAnimation.cpp | 145 |
1 files changed, 63 insertions, 82 deletions
diff --git a/ZAPD/ZAnimation.cpp b/ZAPD/ZAnimation.cpp index ecbda49..9163d62 100644 --- a/ZAPD/ZAnimation.cpp +++ b/ZAPD/ZAnimation.cpp @@ -9,7 +9,11 @@ using namespace std; -ZAnimation::ZAnimation() : ZResource() +REGISTER_ZFILENODE(Animation, ZNormalAnimation); +REGISTER_ZFILENODE(PlayerAnimation, ZLinkAnimation); +REGISTER_ZFILENODE(CurveAnimation, ZCurveAnimation); + +ZAnimation::ZAnimation(ZFile* nParent) : ZResource(nParent) { frameCount = 0; } @@ -49,7 +53,7 @@ ZResourceType ZAnimation::GetResourceType() return ZResourceType::Animation; } -ZNormalAnimation::ZNormalAnimation() : ZAnimation() +ZNormalAnimation::ZNormalAnimation(ZFile* nParent) : ZAnimation(nParent) { rotationValues = vector<uint16_t>(); rotationIndices = vector<RotationIndex>(); @@ -117,17 +121,14 @@ std::string ZNormalAnimation::GetSourceTypeName() return "AnimationHeader"; } -ZNormalAnimation* ZNormalAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, - std::vector<uint8_t> nRawData, int rawDataIndex, - const std::string& nRelPath) +void ZNormalAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, + const std::vector<uint8_t>& nRawData, const int nRawDataIndex, + const std::string& nRelPath) { - ZNormalAnimation* anim = new ZNormalAnimation(); - anim->rawData = std::move(nRawData); - anim->rawDataIndex = rawDataIndex; - anim->ParseXML(reader); - anim->ParseRawData(); - - return anim; + rawData = std::move(nRawData); + rawDataIndex = nRawDataIndex; + ParseXML(reader); + ParseRawData(); } void ZNormalAnimation::ParseRawData() @@ -161,7 +162,7 @@ void ZNormalAnimation::ParseRawData() } } -ZLinkAnimation::ZLinkAnimation() : ZAnimation() +ZLinkAnimation::ZLinkAnimation(ZFile* nParent) : ZAnimation(nParent) { segmentAddress = 0; } @@ -194,17 +195,14 @@ std::string ZLinkAnimation::GetSourceTypeName() return "LinkAnimationHeader"; } -ZLinkAnimation* ZLinkAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, - std::vector<uint8_t> nRawData, int rawDataIndex, - const std::string& nRelPath) +void ZLinkAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, + const std::vector<uint8_t>& nRawData, const int nRawDataIndex, + const std::string& nRelPath) { - ZLinkAnimation* anim = new ZLinkAnimation(); - anim->rawData = std::move(nRawData); - anim->rawDataIndex = rawDataIndex; - anim->ParseXML(reader); - anim->ParseRawData(); - - return anim; + rawData = std::move(nRawData); + rawDataIndex = nRawDataIndex; + ParseXML(reader); + ParseRawData(); } void ZLinkAnimation::ParseRawData() @@ -252,56 +250,8 @@ std::string TransformData::GetSourceTypeName() return "TransformData"; } -ZCurveAnimation::ZCurveAnimation(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, - int nRawDataIndex, ZFile* nParent) +ZCurveAnimation::ZCurveAnimation(ZFile* nParent) : ZAnimation(nParent) { - rawData.assign(nRawData.begin(), nRawData.end()); - rawDataIndex = nRawDataIndex; - parent = nParent; - - ParseXML(reader); - ParseRawData(); - - skel = new ZSkeleton(ZSkeletonType::Curve, ZLimbType::Curve, "CurveAnim", nRawData, - Seg2Filespace(skelOffset, parent->baseAddress), nParent); - - size_t transformDataSize = 0; - size_t copyValuesSize = 0; - if (refIndex != 0) - { - uint32_t refIndexOffset = Seg2Filespace(refIndex, parent->baseAddress); - for (size_t i = 0; i < 3 * 3 * skel->GetLimbCount(); i++) - { - uint8_t ref = BitConverter::ToUInt8BE(nRawData, refIndexOffset + i); - if (ref == 0) - { - copyValuesSize++; - } - else - { - transformDataSize += ref; - } - refIndexArr.emplace_back(ref); - } - } - - if (transformData != 0) - { - uint32_t transformDataOffset = Seg2Filespace(transformData, parent->baseAddress); - for (size_t i = 0; i < transformDataSize; i++) - { - transformDataArr.emplace_back(parent, nRawData, transformDataOffset, i); - } - } - - if (copyValues != 0) - { - uint32_t copyValuesOffset = Seg2Filespace(copyValues, parent->baseAddress); - for (size_t i = 0; i < copyValuesSize; i++) - { - copyValuesArr.emplace_back(BitConverter::ToInt16BE(nRawData, copyValuesOffset + i * 2)); - } - } } ZCurveAnimation::~ZCurveAnimation() @@ -335,19 +285,50 @@ void ZCurveAnimation::ParseRawData() unk_10 = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); } -ZCurveAnimation* ZCurveAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, - const std::vector<uint8_t>& nRawData, - int nRawDataIndex, std::string nRelPath, - ZFile* nParent) +void ZCurveAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, + const std::vector<uint8_t>& nRawData, const int nRawDataIndex, + const std::string& nRelPath) { - ZCurveAnimation* curve = new ZCurveAnimation(reader, nRawData, nRawDataIndex, nParent); - curve->relativePath = std::move(nRelPath); + ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex, nRelPath); + + skel = new ZSkeleton(ZSkeletonType::Curve, ZLimbType::Curve, "CurveAnim", nRawData, + Seg2Filespace(skelOffset, parent->baseAddress), parent); - curve->parent->AddDeclaration(curve->rawDataIndex, DeclarationAlignment::Align16, - curve->GetRawDataSize(), curve->GetSourceTypeName(), curve->name, - ""); + size_t transformDataSize = 0; + size_t copyValuesSize = 0; + if (refIndex != 0) + { + uint32_t refIndexOffset = Seg2Filespace(refIndex, parent->baseAddress); + for (size_t i = 0; i < 3 * 3 * skel->GetLimbCount(); i++) + { + uint8_t ref = BitConverter::ToUInt8BE(nRawData, refIndexOffset + i); + if (ref == 0) + copyValuesSize++; + else + transformDataSize += ref; + + refIndexArr.emplace_back(ref); + } + } + + if (transformData != 0) + { + uint32_t transformDataOffset = Seg2Filespace(transformData, parent->baseAddress); + + for (size_t i = 0; i < transformDataSize; i++) + transformDataArr.emplace_back(parent, nRawData, transformDataOffset, i); + } + + if (copyValues != 0) + { + uint32_t copyValuesOffset = Seg2Filespace(copyValues, parent->baseAddress); + + for (size_t i = 0; i < copyValuesSize; i++) + copyValuesArr.emplace_back(BitConverter::ToInt16BE(nRawData, copyValuesOffset + i * 2)); + } - return curve; + parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align16, GetRawDataSize(), + GetSourceTypeName(), name, ""); } void ZCurveAnimation::PreGenValues(const std::string& prefix) |
