1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
#include "EADLimbFactory.h"
#include "utils/Decompressor.h"
#include "spdlog/spdlog.h"
#include "Companion.h"
#define FORMAT_HEX(x) std::hex << "0x" << std::uppercase << x << std::nouppercase << std::dec
#define FZX_LIMB_SIZE 0x36
ExportResult FZX::EADLimbHeaderExporter::Export(std::ostream& write, std::shared_ptr<IParsedData> raw,
std::string& entryName, YAML::Node& node, std::string* replacement) {
const auto symbol = GetSafeNode(node, "symbol", entryName);
if (Companion::Instance->IsOTRMode()) {
write << "static const ALIGN_ASSET(2) char " << symbol << "[] = \"__OTR__" << (*replacement) << "\";\n\n";
return std::nullopt;
}
write << "extern EADDemoLimb " << symbol << ";\n";
return std::nullopt;
}
ExportResult FZX::EADLimbCodeExporter::Export(std::ostream& write, std::shared_ptr<IParsedData> raw,
std::string& entryName, YAML::Node& node, std::string* replacement) {
const auto symbol = GetSafeNode(node, "symbol", entryName);
const auto offset = GetSafeNode<uint32_t>(node, "offset");
const auto limb = std::static_pointer_cast<EADLimbData>(raw);
write << "EADDemoLimb " << symbol << " = {\n";
write << fourSpaceTab;
if (limb->mDl == 0) {
write << "NULL,\n";
} else {
auto dec = Companion::Instance->GetNodeByAddr(limb->mDl);
if (dec.has_value()) {
auto node = std::get<1>(dec.value());
auto assetSymbol = GetSafeNode<std::string>(node, "symbol");
write << assetSymbol << ",\n";
} else {
write << FORMAT_HEX(limb->mDl) << ",\n";
}
}
write << fourSpaceTab << limb->mScale << ",\n";
write << fourSpaceTab << limb->mPos << ",\n";
write << fourSpaceTab << limb->mRot << ",\n";
write << fourSpaceTab;
if (limb->mNextLimb == 0) {
write << "NULL,\n";
} else {
auto dec = Companion::Instance->GetNodeByAddr(limb->mNextLimb);
if (dec.has_value()) {
auto node = std::get<1>(dec.value());
auto assetSymbol = GetSafeNode<std::string>(node, "symbol");
write << "&" << assetSymbol << ",\n";
} else {
write << FORMAT_HEX(limb->mNextLimb) << ",\n";
}
}
write << fourSpaceTab;
if (limb->mChildLimb == 0) {
write << "NULL,\n";
} else {
auto dec = Companion::Instance->GetNodeByAddr(limb->mChildLimb);
if (dec.has_value()) {
auto node = std::get<1>(dec.value());
auto assetSymbol = GetSafeNode<std::string>(node, "symbol");
write << "&" << assetSymbol << ",\n";
} else {
write << FORMAT_HEX(limb->mChildLimb) << ",\n";
}
}
write << fourSpaceTab;
if (limb->mAssociatedLimb == 0) {
write << "NULL,\n";
} else {
auto dec = Companion::Instance->GetNodeByAddr(limb->mAssociatedLimb);
if (dec.has_value()) {
auto node = std::get<1>(dec.value());
auto assetSymbol = GetSafeNode<std::string>(node, "symbol");
write << "&" << assetSymbol << ",\n";
} else {
write << FORMAT_HEX(limb->mAssociatedLimb) << ",\n";
}
}
write << fourSpaceTab;
if (limb->mAssociatedLimbDL == 0) {
write << "NULL,\n";
} else {
auto dec = Companion::Instance->GetNodeByAddr(limb->mAssociatedLimbDL);
if (dec.has_value()) {
auto node = std::get<1>(dec.value());
auto assetSymbol = GetSafeNode<std::string>(node, "symbol");
write << assetSymbol << ",\n";
} else {
write << FORMAT_HEX(limb->mAssociatedLimbDL) << ",\n";
}
}
write << fourSpaceTab << limb->mLimbId << "\n};\n\n";
return offset + FZX_LIMB_SIZE;
}
ExportResult FZX::EADLimbBinaryExporter::Export(std::ostream& write, std::shared_ptr<IParsedData> raw,
std::string& entryName, YAML::Node& node, std::string* replacement) {
auto writer = LUS::BinaryWriter();
const auto limb = std::static_pointer_cast<EADLimbData>(raw);
return std::nullopt;
}
std::optional<std::shared_ptr<IParsedData>> FZX::EADLimbFactory::parse(std::vector<uint8_t>& buffer, YAML::Node& node) {
auto [_, segment] = Decompressor::AutoDecode(node, buffer);
LUS::BinaryReader reader(segment.data, segment.size);
reader.SetEndianness(Torch::Endianness::Big);
Vec3f scale;
Vec3f pos;
Vec3s rot;
auto dl = reader.ReadUInt32();
if (dl != 0) {
YAML::Node dListNode;
dListNode["type"] = "GFX";
dListNode["offset"] = dl;
Companion::Instance->AddAsset(dListNode);
}
scale.x = reader.ReadFloat();
scale.y = reader.ReadFloat();
scale.z = reader.ReadFloat();
pos.x = reader.ReadFloat();
pos.y = reader.ReadFloat();
pos.z = reader.ReadFloat();
rot.x = reader.ReadInt16();
rot.y = reader.ReadInt16();
rot.z = reader.ReadInt16();
reader.ReadInt16();
auto nextLimb = reader.ReadUInt32();
auto childLimb = reader.ReadUInt32();
auto associatedLimb = reader.ReadUInt32();
auto associatedLimbDL = reader.ReadUInt32();
if (associatedLimbDL != 0) {
YAML::Node dListNode;
dListNode["type"] = "GFX";
dListNode["offset"] = associatedLimbDL;
Companion::Instance->AddAsset(dListNode);
}
auto limbId = reader.ReadInt16();
return std::make_shared<EADLimbData>(dl, scale, pos, rot, nextLimb, childLimb, associatedLimb, associatedLimbDL,
limbId);
}
|