mirror of
https://github.com/izzy2lost/Torch.git
synced 2026-07-06 00:18:35 -07:00
Implement tables for LightsFactory
This commit is contained in:
@@ -12,39 +12,94 @@ ExportResult LightsHeaderExporter::Export(std::ostream &write, std::shared_ptr<I
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
write << "extern Lights1 " << symbol << ";\n";
|
||||
const auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
const auto searchTable = Companion::Instance->SearchTable(offset);
|
||||
|
||||
if(searchTable.has_value()){
|
||||
const auto [name, start, end, mode] = searchTable.value();
|
||||
|
||||
if(start != offset){
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
write << "extern Lights1" << name << "[];\n";
|
||||
} else {
|
||||
write << "extern Lights1 " << symbol << ";\n";
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
ExportResult LightsCodeExporter::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 symbol = GetSafeNode(node, "symbol", entryName);
|
||||
const auto offset = GetSafeNode<uint32_t>(node, "offset");
|
||||
const auto searchTable = Companion::Instance->SearchTable(offset);
|
||||
|
||||
write << "Lights1 " << symbol << " = gdSPDefLights1(\n";
|
||||
if(searchTable.has_value()){
|
||||
const auto [name, start, end, mode] = searchTable.value();
|
||||
|
||||
|
||||
// Ambient
|
||||
auto r = (int16_t) light.a.l.col[0];
|
||||
auto g = (int16_t) light.a.l.col[1];
|
||||
auto b = (int16_t) light.a.l.col[2];
|
||||
if(start == offset){
|
||||
write << "Lights1 " << name << "[] = {\n";
|
||||
}
|
||||
|
||||
// Diffuse
|
||||
auto r2 = (int16_t) light.l[0].l.col[0];
|
||||
auto g2 = (int16_t) light.l[0].l.col[1];
|
||||
auto b2 = (int16_t) light.l[0].l.col[2];
|
||||
// Ambient
|
||||
auto r = (int16_t) light.a.l.col[0];
|
||||
auto g = (int16_t) light.a.l.col[1];
|
||||
auto b = (int16_t) light.a.l.col[2];
|
||||
|
||||
// Direction
|
||||
auto x = (int16_t) light.l[0].l.dir[0];
|
||||
auto y = (int16_t) light.l[0].l.dir[1];
|
||||
auto z = (int16_t) light.l[0].l.dir[2];
|
||||
// Diffuse
|
||||
auto r2 = (int16_t) light.l[0].l.col[0];
|
||||
auto g2 = (int16_t) light.l[0].l.col[1];
|
||||
auto b2 = (int16_t) light.l[0].l.col[2];
|
||||
|
||||
SPDLOG_INFO("Read light: {:X} {:X} {:X} {:X} {:X}", r, g, b, r2, g2);
|
||||
// Direction
|
||||
auto x = (int16_t) light.l[0].l.dir[0];
|
||||
auto y = (int16_t) light.l[0].l.dir[1];
|
||||
auto z = (int16_t) light.l[0].l.dir[2];
|
||||
|
||||
write << fourSpaceTab;
|
||||
write << r << ", " << g << ", " << b << ",\n";
|
||||
write << fourSpaceTab;
|
||||
write << r2 << ", " << g2 << ", " << b2 << ", " << x << ", " << y << ", " << z << "\n";
|
||||
SPDLOG_INFO("Read light: {:X} {:X} {:X} {:X} {:X}", r, g, b, r2, g2);
|
||||
|
||||
write << ");\n\n";
|
||||
write << fourSpaceTab << "gdSPDefLights1(\n";
|
||||
|
||||
write << fourSpaceTab;
|
||||
write << r << ", " << g << ", " << b << ",\n";
|
||||
write << fourSpaceTab;
|
||||
write << r2 << ", " << g2 << ", " << b2 << ", " << x << ", " << y << ", " << z << "\n";
|
||||
|
||||
write << fourSpaceTab << "),\n";
|
||||
|
||||
if (end == offset) {
|
||||
write << "};\n\n";
|
||||
}
|
||||
|
||||
} else {
|
||||
write << "Lights1 " << symbol << " = gdSPDefLights1(\n";
|
||||
|
||||
// Ambient
|
||||
auto r = (int16_t) light.a.l.col[0];
|
||||
auto g = (int16_t) light.a.l.col[1];
|
||||
auto b = (int16_t) light.a.l.col[2];
|
||||
|
||||
// Diffuse
|
||||
auto r2 = (int16_t) light.l[0].l.col[0];
|
||||
auto g2 = (int16_t) light.l[0].l.col[1];
|
||||
auto b2 = (int16_t) light.l[0].l.col[2];
|
||||
|
||||
// Direction
|
||||
auto x = (int16_t) light.l[0].l.dir[0];
|
||||
auto y = (int16_t) light.l[0].l.dir[1];
|
||||
auto z = (int16_t) light.l[0].l.dir[2];
|
||||
|
||||
SPDLOG_INFO("Read light: {:X} {:X} {:X} {:X} {:X}", r, g, b, r2, g2);
|
||||
|
||||
write << fourSpaceTab;
|
||||
write << r << ", " << g << ", " << b << ",\n";
|
||||
write << fourSpaceTab;
|
||||
write << r2 << ", " << g2 << ", " << b2 << ", " << x << ", " << y << ", " << z << "\n";
|
||||
|
||||
write << ");\n\n";
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user