1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-17 04:20:44 +00:00
oot/tools/ZAPD/ZAPD/ZAnimation.h
Anghelo Carvajal 515ebdce9d
ZAPD update: libpng, zroom improvements and others (#811)
* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "769f5702a"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "769f5702a"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* Add `libpng` to readme

* Remove `-ifp` since it doesn't exists anymore in ZAPD

* Remove extra print I added

* Add UNK_09 macro and other minor fixes

* Simplify PNG rules

* simplify gitignore

* Update README.md

Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>

* Update dockerfile

* basic instructions for cygwin and mac

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "86160be69"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "86160be69"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* Change nanoseconds to seconds in extract_assets.py

Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
2021-05-30 11:09:59 -04:00

138 lines
3.1 KiB
C++

#pragma once
#include <stdint.h>
#include <string>
#include <vector>
#include "Vec3s.h"
#include "ZResource.h"
#include "ZSkeleton.h"
#include "tinyxml2.h"
struct RotationIndex
{
// uint16_t transX, transY, transZ;
uint16_t x, y, z;
RotationIndex(uint16_t nX, uint16_t nY, uint16_t nZ)
{
x = nX;
y = nY;
z = nZ;
};
};
class ZAnimation : public ZResource
{
public:
int16_t frameCount;
ZAnimation(ZFile* nParent);
std::string GetSourceOutputCode(const std::string& prefix) override;
ZResourceType GetResourceType() const override;
protected:
void ParseRawData() override;
void Save(const fs::path& outFolder) override;
};
class ZNormalAnimation : public ZAnimation
{
public:
std::vector<uint16_t> rotationValues;
std::vector<RotationIndex> rotationIndices;
uint32_t rotationValuesSeg;
uint32_t rotationIndicesSeg;
int16_t limit;
ZNormalAnimation(ZFile* nParent);
std::string GetSourceOutputCode(const std::string& prefix) override;
size_t GetRawDataSize() const override;
std::string GetSourceTypeName() const override;
protected:
virtual void ParseRawData() override;
};
class ZLinkAnimation : public ZAnimation
{
public:
segptr_t segmentAddress;
ZLinkAnimation(ZFile* nParent);
std::string GetSourceOutputCode(const std::string& prefix) override;
size_t GetRawDataSize() const override;
std::string GetSourceTypeName() const override;
protected:
virtual void ParseRawData() override;
};
class TransformData
{
protected:
ZFile* parent;
///* 0x0000 */ u16 unk_00; // appears to be flags
uint16_t unk_00;
///* 0x0002 */ s16 unk_02;
int16_t unk_02;
///* 0x0004 */ s16 unk_04;
int16_t unk_04;
///* 0x0006 */ s16 unk_06;
int16_t unk_06;
///* 0x0008 */ f32 unk_08;
float unk_08;
public:
TransformData() = default;
TransformData(ZFile* parent, const std::vector<uint8_t>& rawData, uint32_t fileOffset);
TransformData(ZFile* parent, const std::vector<uint8_t>& rawData, uint32_t fileOffset,
size_t index);
[[nodiscard]] std::string GetBody(const std::string& prefix) const;
size_t GetRawDataSize() const;
std::string GetSourceTypeName();
};
class ZCurveAnimation : public ZAnimation
{
protected:
segptr_t skelOffset = 0;
///* 0x0000 */ u8* refIndex;
segptr_t refIndex = 0;
///* 0x0004 */ TransformData* transformData;
segptr_t transformData = 0;
///* 0x0008 */ s16* copyValues;
segptr_t copyValues = 0;
///* 0x000C */ s16 unk_0C;
int16_t unk_0C;
///* 0x000E */ s16 unk_10;
int16_t unk_10;
uint8_t limbCount = 0;
std::vector<uint8_t> refIndexArr;
std::vector<TransformData> transformDataArr;
std::vector<int16_t> copyValuesArr;
public:
ZCurveAnimation();
ZCurveAnimation(ZFile* nParent);
void ParseXML(tinyxml2::XMLElement* reader) override;
void ParseRawData() override;
void ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
const uint32_t nRawDataIndex) override;
void DeclareReferences(const std::string& prefix) override;
size_t GetRawDataSize() const override;
std::string GetSourceOutputCode(const std::string& prefix) override;
std::string GetSourceTypeName() const override;
};
// TransformUpdateIndex