From a29291d139764b251536282b3fd716ffa877e3d7 Mon Sep 17 00:00:00 2001 From: Nicholas Estelami Date: Fri, 1 Jan 2021 19:33:17 -0500 Subject: Added in support for player animations (#40) * Added in support for Player Animations * Fixed up a bunch of non matching issues --- ZAPD/ZAnimation.cpp | 138 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 102 insertions(+), 36 deletions(-) (limited to 'ZAPD/ZAnimation.cpp') diff --git a/ZAPD/ZAnimation.cpp b/ZAPD/ZAnimation.cpp index c420909..c0fa085 100644 --- a/ZAPD/ZAnimation.cpp +++ b/ZAPD/ZAnimation.cpp @@ -11,20 +11,6 @@ using namespace std; ZAnimation::ZAnimation() : ZResource() { frameCount = 0; - rotationValues = vector(); - rotationIndices = vector(); - limit = 0; -} - -ZAnimation* ZAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, vector nRawData, int rawDataIndex, string nRelPath) -{ - ZAnimation* anim = new ZAnimation(); - anim->rawData = nRawData; - anim->rawDataIndex = rawDataIndex; - anim->ParseXML(reader); - anim->ParseRawData(); - - return anim; } void ZAnimation::ParseRawData() @@ -33,27 +19,6 @@ void ZAnimation::ParseRawData() // Read the header frameCount = BitConverter::ToInt16BE(data, rawDataIndex + 0); - rotationValuesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 4) & 0x00FFFFFF; - rotationIndicesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 8) & 0x00FFFFFF; - limit = BitConverter::ToInt16BE(data, rawDataIndex + 12); - - uint32_t currentPtr = rotationValuesSeg; - - // Read the Rotation Values - for (int i = 0; i < ((rotationIndicesSeg - rotationValuesSeg) / 2); i++) - { - rotationValues.push_back(BitConverter::ToInt16BE(data, currentPtr)); - currentPtr += 2; - } - - currentPtr = rotationIndicesSeg; - - // Read the Rotation Indices - for (int i = 0; i < ((rawDataIndex - rotationIndicesSeg) / 6); i++) - { - rotationIndices.push_back(RotationIndex(BitConverter::ToInt16BE(data, currentPtr), BitConverter::ToInt16BE(data, currentPtr + 2), BitConverter::ToInt16BE(data, currentPtr + 4))); - currentPtr += 6; - } } void ZAnimation::Save(string outFolder) @@ -76,6 +41,18 @@ void ZAnimation::ParseXML(tinyxml2::XMLElement* reader) } string ZAnimation::GetSourceOutputCode(string prefix) +{ + return ""; +} + +ZNormalAnimation::ZNormalAnimation() : ZAnimation() +{ + rotationValues = vector(); + rotationIndices = vector(); + limit = 0; +} + +std::string ZNormalAnimation::GetSourceOutputCode(std::string prefix) { if (parent != nullptr) { @@ -112,4 +89,93 @@ string ZAnimation::GetSourceOutputCode(string prefix) } return ""; -} \ No newline at end of file +} + +int ZNormalAnimation::GetRawDataSize() +{ + return 16; +} + +ZNormalAnimation* ZNormalAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, std::vector nRawData, int rawDataIndex, std::string nRelPath) +{ + ZNormalAnimation* anim = new ZNormalAnimation(); + anim->rawData = nRawData; + anim->rawDataIndex = rawDataIndex; + anim->ParseXML(reader); + anim->ParseRawData(); + + return anim; +} + +void ZNormalAnimation::ParseRawData() +{ + ZAnimation::ParseRawData(); + + uint8_t* data = rawData.data(); + + rotationValuesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 4) & 0x00FFFFFF; + rotationIndicesSeg = BitConverter::ToInt32BE(data, rawDataIndex + 8) & 0x00FFFFFF; + limit = BitConverter::ToInt16BE(data, rawDataIndex + 12); + + uint32_t currentPtr = rotationValuesSeg; + + // Read the Rotation Values + for (int i = 0; i < ((rotationIndicesSeg - rotationValuesSeg) / 2); i++) + { + rotationValues.push_back(BitConverter::ToInt16BE(data, currentPtr)); + currentPtr += 2; + } + + currentPtr = rotationIndicesSeg; + + // Read the Rotation Indices + for (int i = 0; i < ((rawDataIndex - rotationIndicesSeg) / 6); i++) + { + rotationIndices.push_back(RotationIndex(BitConverter::ToInt16BE(data, currentPtr), BitConverter::ToInt16BE(data, currentPtr + 2), BitConverter::ToInt16BE(data, currentPtr + 4))); + currentPtr += 6; + } +} + +ZLinkAnimation::ZLinkAnimation() : ZAnimation() +{ + segmentAddress = 0; +} + +std::string ZLinkAnimation::GetSourceOutputCode(std::string prefix) +{ + if (parent != nullptr) + { + string segSymbol = segmentAddress == 0 ? "NULL" : parent->GetDeclarationName(segmentAddress, StringHelper::Sprintf("%sSeg%06X", name.c_str(), segmentAddress)); + string headerStr = StringHelper::Sprintf("%i, 0x%08X", + frameCount, segmentAddress); + parent->declarations[rawDataIndex] = new Declaration(DeclarationAlignment::None, 16, "LinkAnimationHeader", StringHelper::Sprintf("%s", name.c_str()), false, headerStr); + } + + return ""; +} + +int ZLinkAnimation::GetRawDataSize() +{ + return 8; +} + +ZLinkAnimation* ZLinkAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, std::vector nRawData, int rawDataIndex, std::string nRelPath) +{ + ZLinkAnimation* anim = new ZLinkAnimation(); + anim->rawData = nRawData; + anim->rawDataIndex = rawDataIndex; + anim->ParseXML(reader); + anim->ParseRawData(); + + return anim; +} + +void ZLinkAnimation::ParseRawData() +{ + ZAnimation::ParseRawData(); + + uint8_t* data = rawData.data(); + + //segmentAddress = SEG2FILESPACE(BitConverter::ToInt32BE(data, rawDataIndex + 4)); + segmentAddress = (BitConverter::ToInt32BE(data, rawDataIndex + 4)); +} -- cgit v1.2.3