mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-14 19:10:25 +00:00
* First batch of files * Add missing folders back * Fix missing folders again * Finish fixing existing texture files * Gameplay_Keep XML finished * Most actor gameplay_keep undefined syms removed * Only ~200 gkeep symbols remain * All gkeep symbols that ZAP supports are fixed * Cleanup, and make gkeep names more accurate * Starting to figure out what some unknown blobs are, merge zeldaret in * fix a few more things * refactor gkeep * Change how gitkeep is handled * gkeep xml cleanup * Gkeep finished, now just waiting up ZAP updates * 100 link animations finished * 150 link animations finished * 200 link animations finished * 250 link animations finished * 350 link animations finished * 400 link animations finished * 450 link animations finished * 500 link animations finished * 550 link animations finished * All Link animations finished cannot build yet because ZAP doesn't have LinkAnimationHeader yet * xml changes for new zap stuff * finish gameplay_keep * fixing existing objects * ready for pr besides zap padding issue * mostly ready for pr * format all c files * all conflicts fixed * make changes that roman requested * fix thing i didn't mean to change * some animation symbols renamed * fixed roman's stuff * lifemeter hardcoded pointers removed * fix issue with incorrect data in gameplay_keep * removed unused asm * fixed most of fig's comments * fix all of fig's comments * reformat files * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * fixed stuff * fixed most of roman's comments * remove leading zeroes * should build now * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "f84d8337b" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "f84d8337b" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * all of gkeep symbols fixed * compiler error fixed * format files * final changes Co-authored-by: Zelllll <elijah@DESKTOP-NMP1I89.localdomain> Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
188 lines
5.2 KiB
C++
188 lines
5.2 KiB
C++
#include "ZAnimation.h"
|
|
#include <utility>
|
|
#include "ZFile.h"
|
|
#include "BitConverter.h"
|
|
#include "StringHelper.h"
|
|
#include "File.h"
|
|
#include "HighLevel/HLAnimationIntermediette.h"
|
|
#include "Globals.h"
|
|
|
|
using namespace std;
|
|
|
|
ZAnimation::ZAnimation() : ZResource()
|
|
{
|
|
frameCount = 0;
|
|
}
|
|
|
|
void ZAnimation::ParseRawData()
|
|
{
|
|
const uint8_t* data = rawData.data();
|
|
|
|
// Read the header
|
|
frameCount = BitConverter::ToInt16BE(data, rawDataIndex + 0);
|
|
}
|
|
|
|
void ZAnimation::Save(const std::string& outFolder)
|
|
{
|
|
if (Globals::Instance->testMode)
|
|
{
|
|
HLAnimationIntermediette* anim = HLAnimationIntermediette::FromZAnimation(this);
|
|
string xml = anim->OutputXML();
|
|
File::WriteAllText(outFolder + "/" + name + ".anmi", xml);
|
|
|
|
delete anim;
|
|
}
|
|
}
|
|
|
|
void ZAnimation::ParseXML(tinyxml2::XMLElement* reader)
|
|
{
|
|
ZResource::ParseXML(reader);
|
|
}
|
|
|
|
string ZAnimation::GetSourceOutputCode(const std::string& prefix)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
ZResourceType ZAnimation::GetResourceType()
|
|
{
|
|
return ZResourceType::Animation;
|
|
}
|
|
|
|
ZNormalAnimation::ZNormalAnimation() : ZAnimation()
|
|
{
|
|
rotationValues = vector<uint16_t>();
|
|
rotationIndices = vector<RotationIndex>();
|
|
limit = 0;
|
|
}
|
|
|
|
std::string ZNormalAnimation::GetSourceOutputCode(const std::string& prefix)
|
|
{
|
|
if (parent != nullptr)
|
|
{
|
|
string defaultPrefix = name.c_str();
|
|
defaultPrefix.replace(0, 1, "s"); // replace g prefix with s for local variables
|
|
|
|
string headerStr = StringHelper::Sprintf("{ %i }, %sFrameData, %sJointIndices, %i",
|
|
frameCount, defaultPrefix.c_str(), defaultPrefix.c_str(), limit);
|
|
parent->AddDeclaration(rawDataIndex, DeclarationAlignment::None, 16, "AnimationHeader", StringHelper::Sprintf("%s", name.c_str()), headerStr);
|
|
|
|
string indicesStr = "";
|
|
string valuesStr = " ";
|
|
const int lineLength = 14;
|
|
const int offset = 0;
|
|
|
|
for (int i = 0; i < rotationValues.size(); i++)
|
|
{
|
|
valuesStr += StringHelper::Sprintf("0x%04X, ", rotationValues[i]);
|
|
|
|
if ((i - offset + 1) % lineLength == 0)
|
|
valuesStr += "\n ";
|
|
}
|
|
|
|
for (int i = 0; i < rotationIndices.size(); i++)
|
|
{
|
|
indicesStr += StringHelper::Sprintf(" { 0x%04X, 0x%04X, 0x%04X },", rotationIndices[i].x, rotationIndices[i].y, rotationIndices[i].z);
|
|
|
|
if (i != (rotationIndices.size() - 1))
|
|
indicesStr += "\n";
|
|
}
|
|
|
|
parent->AddDeclarationArray(rotationValuesSeg, DeclarationAlignment::Align16, (int)rotationValues.size() * 2, "static s16",
|
|
StringHelper::Sprintf("%sFrameData", defaultPrefix.c_str()), rotationValues.size(), valuesStr);
|
|
|
|
parent->AddDeclarationArray(rotationIndicesSeg, DeclarationAlignment::Align16, (int)rotationIndices.size() * 6, "static JointIndex",
|
|
StringHelper::Sprintf("%sJointIndices", defaultPrefix.c_str()), rotationIndices.size(), indicesStr);
|
|
}
|
|
|
|
return "";
|
|
}
|
|
|
|
int ZNormalAnimation::GetRawDataSize()
|
|
{
|
|
return 16;
|
|
}
|
|
|
|
ZNormalAnimation* ZNormalAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, const std::string& nRelPath)
|
|
{
|
|
ZNormalAnimation* anim = new ZNormalAnimation();
|
|
anim->rawData = std::move(nRawData);
|
|
anim->rawDataIndex = rawDataIndex;
|
|
anim->ParseXML(reader);
|
|
anim->ParseRawData();
|
|
|
|
return anim;
|
|
}
|
|
|
|
void ZNormalAnimation::ParseRawData()
|
|
{
|
|
ZAnimation::ParseRawData();
|
|
|
|
const 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(const 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->AddDeclaration(rawDataIndex, DeclarationAlignment::None, 16, "LinkAnimationHeader", StringHelper::Sprintf("%s", name.c_str()), headerStr);
|
|
}
|
|
|
|
return "";
|
|
}
|
|
|
|
int ZLinkAnimation::GetRawDataSize()
|
|
{
|
|
return 8;
|
|
}
|
|
|
|
ZLinkAnimation* ZLinkAnimation::ExtractFromXML(tinyxml2::XMLElement* reader, std::vector<uint8_t> nRawData, int rawDataIndex, const std::string& nRelPath)
|
|
{
|
|
ZLinkAnimation* anim = new ZLinkAnimation();
|
|
anim->rawData = std::move(nRawData);
|
|
anim->rawDataIndex = rawDataIndex;
|
|
anim->ParseXML(reader);
|
|
anim->ParseRawData();
|
|
|
|
return anim;
|
|
}
|
|
|
|
void ZLinkAnimation::ParseRawData()
|
|
{
|
|
ZAnimation::ParseRawData();
|
|
|
|
const uint8_t* data = rawData.data();
|
|
|
|
//segmentAddress = SEG2FILESPACE(BitConverter::ToInt32BE(data, rawDataIndex + 4));
|
|
segmentAddress = (BitConverter::ToInt32BE(data, rawDataIndex + 4));
|
|
}
|