summaryrefslogtreecommitdiff
path: root/src/factories/mk64/CourseVtx.cpp
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2024-05-07 13:23:16 -0600
committerLywx <kiritodev01@gmail.com>2024-05-07 22:00:44 -0600
commitfa8654bbb9a7b062008255a87773b5e537494bd4 (patch)
tree379a0fb44bdd5fab74566b1df379650ce0374ae3 /src/factories/mk64/CourseVtx.cpp
parent45e6853e315933d57a0e7213a2d5590fb74f628a (diff)
Convert CourseVtx to Vtx
Diffstat (limited to 'src/factories/mk64/CourseVtx.cpp')
-rw-r--r--src/factories/mk64/CourseVtx.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/factories/mk64/CourseVtx.cpp b/src/factories/mk64/CourseVtx.cpp
index d0e32db..d7bb122 100644
--- a/src/factories/mk64/CourseVtx.cpp
+++ b/src/factories/mk64/CourseVtx.cpp
@@ -14,7 +14,7 @@ ExportResult MK64::CourseVtxHeaderExporter::Export(std::ostream &write, std::sha
return std::nullopt;
}
- write << "extern CourseVtx " << symbol << "[];\n";
+ write << "extern Vtx " << symbol << "[];\n";
return std::nullopt;
}
@@ -23,7 +23,7 @@ ExportResult MK64::CourseVtxCodeExporter::Export(std::ostream &write, std::share
const auto symbol = GetSafeNode(node, "symbol", entryName);
const auto offset = GetSafeNode<uint32_t>(node, "offset");
- write << "CourseVtx " << symbol << "[] = {\n";
+ write << "Vtx " << symbol << "[] = {\n";
for (int i = 0; i < vtx.size(); ++i) {
auto v = vtx[i];
@@ -32,6 +32,8 @@ ExportResult MK64::CourseVtxCodeExporter::Export(std::ostream &write, std::share
auto y = v.ob[1];
auto z = v.ob[2];
+ auto f = v.flag;
+
auto tc1 = v.tc[0];
auto tc2 = v.tc[1];
@@ -45,23 +47,24 @@ ExportResult MK64::CourseVtxCodeExporter::Export(std::ostream &write, std::share
}
// {{{ x, y, z }, { tc1, tc2 }, { c1, c2, c3, c4 }}}
- write << "{{{" << NUM(x) << ", " << NUM(y) << ", " << NUM(z) << "}, {" << NUM(tc1) << ", " << NUM(tc2) << "}, {" << COL(c1) << ", " << COL(c2) << ", " << COL(c3) << ", " << COL(c4) << "}}},\n";
+ write << "{{{" << NUM(x) << ", " << NUM(y) << ", " << NUM(z) << "}, " << NUM(flag) << " {" << NUM(tc1) << ", " << NUM(tc2) << "}, {" << COL(c1) << ", " << COL(c2) << ", " << COL(c3) << ", " << COL(c4) << "}}},\n";
}
write << "};\n";
- return offset + vtx.size() * sizeof(CourseVtx);
+ return offset + vtx.size() * sizeof(Vtx);
}
ExportResult MK64::CourseVtxBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
auto vtx = std::static_pointer_cast<CourseVtxData>(raw);
auto writer = LUS::BinaryWriter();
- WriteHeader(writer, LUS::ResourceType::CourseVertex, 0);
+ WriteHeader(writer, LUS::ResourceType::Vtx, 0);
writer.Write((uint32_t) vtx->mVtxs.size());
for(auto v : vtx->mVtxs) {
writer.Write(v.ob[0]);
writer.Write(v.ob[1]);
writer.Write(v.ob[2]);
+ writer.Write(v.flag);
writer.Write(v.tc[0]);
writer.Write(v.tc[1]);
writer.Write(v.cn[0]);
@@ -81,21 +84,30 @@ std::optional<std::shared_ptr<IParsedData>> MK64::CourseVtxFactory::parse(std::v
LUS::BinaryReader reader(segment.data, count * sizeof(CourseVtx));
reader.SetEndianness(LUS::Endianness::Big);
- std::vector<CourseVtx> vertices;
+ std::vector<Vtx> vertices;
for(size_t i = 0; i < count; i++) {
- auto x = reader.ReadInt16();
- auto y = reader.ReadInt16();
- auto z = reader.ReadInt16();
- auto tc1 = reader.ReadInt16();
- auto tc2 = reader.ReadInt16();
+ const auto x = reader.ReadInt16();
+ const auto y = reader.ReadInt16();
+ const auto z = reader.ReadInt16();
+ const auto tc1 = reader.ReadInt16();
+ const auto tc2 = reader.ReadInt16();
auto cn1 = reader.ReadUByte();
auto cn2 = reader.ReadUByte();
auto cn3 = reader.ReadUByte();
auto cn4 = reader.ReadUByte();
- vertices.push_back(CourseVtx({
- {x, y, z}, {tc1, tc2}, {cn1, cn2, cn3, cn4}
+ uint16_t flag = cn1 & 3;
+ flag |= (cn2 << 2) & 0xC;
+
+ cn1 &= 0xFC;
+ cn2 &= 0xFC;
+
+ vertices->v.flag = flags;
+ cn4 = 0xFF;
+
+ vertices.push_back(Vtx({
+ {x, y, z}, flag, {tc1, tc2}, {cn1, cn2, cn3, cn4}
}));
}