2020-04-29 18:57:18 +00:00
|
|
|
local M = {}
|
|
|
|
|
2020-04-30 18:10:32 +00:00
|
|
|
function M.write3d(maze, width, height, depth, filename, settings)
|
2020-04-29 18:57:18 +00:00
|
|
|
local out = io.open(filename, "w")
|
|
|
|
out:write("// Generated by multimaze (lua)\n")
|
2020-04-30 10:39:56 +00:00
|
|
|
out:write("// Hit the Render button (F6) to make the preview look better\n")
|
2020-04-29 18:57:18 +00:00
|
|
|
|
2020-04-30 10:39:56 +00:00
|
|
|
out:write("// Uncomment to make the preview look transclucent\n")
|
2020-04-29 18:57:18 +00:00
|
|
|
out:write("// color(\"red\", 0.25)\n");
|
2020-04-30 10:39:56 +00:00
|
|
|
out:write("union() {\n")
|
2020-04-29 18:57:18 +00:00
|
|
|
for z = 0, depth - 1, 1 do
|
|
|
|
for y = 0, height - 1, 1 do
|
|
|
|
for x = 0, width - 1, 1 do
|
2020-04-30 18:10:32 +00:00
|
|
|
if (maze[z][y][x] == "#" and not settings.inverted) or
|
|
|
|
(maze[z][y][x] == " " and settings.inverted) then
|
|
|
|
out:write("\ttranslate(["..x*settings.scale..", "..y*settings.scale..", "..z*settings.scale.."]) cube(size = "..settings.scale..");\n")
|
2020-04-29 18:57:18 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
out:write("}\n")
|
|
|
|
out:close()
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|