diff options
| author | KiritoDv <kiritodev01@gmail.com> | 2024-06-10 17:14:13 -0600 |
|---|---|---|
| committer | KiritoDv <kiritodev01@gmail.com> | 2024-06-10 17:14:13 -0600 |
| commit | 2929503ee3445e596e722c404f143e777e6498c9 (patch) | |
| tree | 60a13623f7d6805f343a0af56a280a4724f0514b /src | |
| parent | 4d3f360d66fdcdbb19c65fecfae42b85488da119 (diff) | |
Fixed generic sm64 animations
Diffstat (limited to 'src')
| -rw-r--r-- | src/factories/sm64/AnimationFactory.cpp | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/src/factories/sm64/AnimationFactory.cpp b/src/factories/sm64/AnimationFactory.cpp index dec28a2..3d9edf6 100644 --- a/src/factories/sm64/AnimationFactory.cpp +++ b/src/factories/sm64/AnimationFactory.cpp @@ -3,7 +3,7 @@ #include "utils/Decompressor.h" -#define ANIMINDEX_COUNT(boneCount) (boneCount + 1) * 6 * sizeof(uint16_t) +#define ANIMINDEX_COUNT(boneCount) (((boneCount) + 1) * 6) ExportResult SM64::AnimationBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) { auto writer = LUS::BinaryWriter(); @@ -35,7 +35,7 @@ ExportResult SM64::AnimationBinaryExporter::Export(std::ostream &write, std::sha std::optional<std::shared_ptr<IParsedData>> SM64::AnimationFactory::parse(std::vector<uint8_t>& buffer, YAML::Node& node) { auto offset = node["offset"]; - auto [_, data] = Decompressor::AutoDecode(node, buffer); + auto [raw, data] = Decompressor::AutoDecode(node, buffer); LUS::BinaryReader header = LUS::BinaryReader(data.data, data.size); header.SetEndianness(Torch::Endianness::Big); @@ -48,31 +48,45 @@ std::optional<std::shared_ptr<IParsedData>> SM64::AnimationFactory::parse(std::v auto valuesAddr = header.ReadUInt32(); auto indexAddr = header.ReadUInt32(); auto length = header.ReadUInt32(); + auto segmented = raw != nullptr; + auto mainData = segmented ? raw->data : data.data; - size_t indexLength = ANIMINDEX_COUNT(unusedBoneCount); + const auto indexLength = ANIMINDEX_COUNT(unusedBoneCount); + const auto valuesSize = !segmented ? length * sizeof(int16_t) : indexAddr - valuesAddr; - LUS::BinaryReader indices = LUS::BinaryReader(data.data + indexAddr, indexLength * sizeof(uint16_t)); + if(segmented) { + valuesAddr = SEGMENT_OFFSET(valuesAddr); + indexAddr = SEGMENT_OFFSET(indexAddr); + } + + SPDLOG_INFO("Offset: 0x{:X}", offset.as<uint32_t>()); + SPDLOG_INFO("Index Addr: 0x{:X}", indexAddr); + SPDLOG_INFO("Values Addr: 0x{:X}", valuesAddr); + SPDLOG_INFO("Values Size: {}", valuesSize / sizeof(int16_t)); + SPDLOG_INFO("Segmented: {}", segmented); + SPDLOG_INFO("Flags: {}", flags); + SPDLOG_INFO("Anim-Y Trans Divisor: {}", animYTransDivisor); + SPDLOG_INFO("Start Frame: {}", startFrame); + SPDLOG_INFO("Loop Start: {}", loopStart); + SPDLOG_INFO("Loop End: {}", loopEnd); + SPDLOG_INFO("Unused Bone Count: {}", unusedBoneCount); + SPDLOG_INFO("Length: {}", length); + + LUS::BinaryReader indices = LUS::BinaryReader(mainData + indexAddr, indexLength * sizeof(uint16_t)); indices.SetEndianness(Torch::Endianness::Big); std::vector<uint16_t> indicesData; for (size_t i = 0; i < indexLength; i++) { indicesData.push_back(indices.ReadUInt16()); + SPDLOG_INFO("Index: {}", indicesData.back()); } - size_t valuesSize = length * sizeof(int16_t); - LUS::BinaryReader values = LUS::BinaryReader(data.data + valuesAddr, valuesSize); + LUS::BinaryReader values = LUS::BinaryReader(mainData + valuesAddr, valuesSize); values.SetEndianness(Torch::Endianness::Big); std::vector<int16_t> valuesData; for (size_t i = 0; i < valuesSize / sizeof(int16_t); i++) { valuesData.push_back(values.ReadInt16()); + SPDLOG_INFO("Value: {}", valuesData.back()); } - SPDLOG_INFO("Flags: {}", flags); - SPDLOG_INFO("Anim-Y Trans Divisor: {}", animYTransDivisor); - SPDLOG_INFO("Start Frame: {}", startFrame); - SPDLOG_INFO("Loop Start: {}", loopStart); - SPDLOG_INFO("Loop End: {}", loopEnd); - SPDLOG_INFO("Unused Bone Count: {}", unusedBoneCount); - SPDLOG_INFO("Length: {}", length); - return std::make_shared<AnimationData>(flags, animYTransDivisor, startFrame, loopStart, loopEnd, unusedBoneCount, length, indicesData, valuesData); }
\ No newline at end of file |
