summaryrefslogtreecommitdiff
path: root/src/factories/LightsFactory.cpp
diff options
context:
space:
mode:
authorKiritoDv <kiritodev01@gmail.com>2024-08-17 18:31:57 -0600
committerKiritoDv <kiritodev01@gmail.com>2024-08-17 18:31:57 -0600
commit243125d6d500deea4ea862ea9678cf795b54b499 (patch)
tree965721fe40af043ae157e2aed08a499754498899 /src/factories/LightsFactory.cpp
parent1f3bdf8a4e91800f8fa077d6d46c6eafea8c99de (diff)
Fixed light export
Diffstat (limited to 'src/factories/LightsFactory.cpp')
-rw-r--r--src/factories/LightsFactory.cpp40
1 files changed, 2 insertions, 38 deletions
diff --git a/src/factories/LightsFactory.cpp b/src/factories/LightsFactory.cpp
index d6aa580..cb5d9b5 100644
--- a/src/factories/LightsFactory.cpp
+++ b/src/factories/LightsFactory.cpp
@@ -106,18 +106,8 @@ ExportResult LightsCodeExporter::Export(std::ostream &write, std::shared_ptr<IPa
ExportResult LightsBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
auto light = std::static_pointer_cast<LightsData>(raw)->mLights;
auto writer = LUS::BinaryWriter();
- auto size = sizeof(light.l) / sizeof(LightRaw);
-
WriteHeader(writer, Torch::ResourceType::Lights, 0);
-
- writer.Write(reinterpret_cast<char*>(light.a.l.col), 3);
-
- writer.Write(static_cast<uint32_t>(size));
-
- for(size_t i = 0; i < size; i++) {
- writer.Write(reinterpret_cast<char*>(light.l[i].l.col), 3);
- writer.Write(reinterpret_cast<char*>(light.l[i].l.dir), 3);
- }
+ writer.Write(reinterpret_cast<char*>(&light), sizeof(Lights1Raw));
writer.Finish(write);
writer.Close();
return std::nullopt;
@@ -127,33 +117,7 @@ std::optional<std::shared_ptr<IParsedData>> LightsFactory::parse(std::vector<uin
auto decoded = Decompressor::AutoDecode(node, buffer);
auto [_, segment] = Decompressor::AutoDecode(node, buffer);
LUS::BinaryReader reader(segment.data, sizeof(Lights1Raw));
-
- reader.SetEndianness(Torch::Endianness::Big);
Lights1Raw lights;
- // Directional light
-
- // Ambient
- auto r = reader.ReadUByte();
- auto g = reader.ReadUByte();
- auto b = reader.ReadUByte();
- //auto nil = reader.ReadInt32();
- reader.Seek(5, LUS::SeekOffsetType::Current);
-
- // Diffuse copy
- auto r2 = reader.ReadUByte();
- auto g2 = reader.ReadUByte();
- auto b2 = reader.ReadUByte();
-
- reader.Seek(5, LUS::SeekOffsetType::Current);
-
- // Direction
- auto x = reader.ReadInt8();
- auto y = reader.ReadInt8();
- auto z = reader.ReadInt8();
-
- // TODO: This is a hack, but it works for now.
- // The struct has several copies/padding. The zeros skip those for gdSPDefLights1.
- lights = {r, g, b, 0, r, g, b, 0, r2, g2, b2, 0, r2, g2, b2, 0, x, y, z};
-
+ reader.Read((char*) &lights, sizeof(Lights1Raw));
return std::make_shared<LightsData>(lights);
}