mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 14:18:13 +01:00
68 lines
2.2 KiB
OpenSCAD
68 lines
2.2 KiB
OpenSCAD
use <square_maze.scad>
|
|
|
|
maze_rows = 8;
|
|
cell_width = 2;
|
|
wall_thickness = 1;
|
|
inner_cube = true;
|
|
travel_all = true;
|
|
|
|
module cube_maze(maze_rows, cell_width, wall_thickness, inner_cube, travel_all) {
|
|
cells_size = cell_width * maze_rows;
|
|
cube_size = cells_size - wall_thickness;
|
|
maze_size = cells_size + wall_thickness;
|
|
|
|
half_wall_thickness = wall_thickness / 2;
|
|
half_cube_size = cube_size / 2;
|
|
half_maze_size = maze_size / 2;
|
|
|
|
origin = half_wall_thickness - half_maze_size;
|
|
|
|
module two_mazes() {
|
|
module one_maze() {
|
|
translate([origin, origin, half_cube_size])
|
|
linear_extrude(wall_thickness)
|
|
square_maze(maze_rows, cell_width, wall_thickness);
|
|
}
|
|
|
|
one_maze();
|
|
rotate([180, 0, 0])
|
|
one_maze();
|
|
}
|
|
|
|
if(inner_cube) {
|
|
cube(cube_size + 0.01, center= true);
|
|
}
|
|
|
|
difference() {
|
|
union() {
|
|
two_mazes();
|
|
rotate([90, 0, 0]) two_mazes();
|
|
rotate([0, 90, 0]) two_mazes();
|
|
}
|
|
|
|
if(travel_all) {
|
|
union() {
|
|
translate([half_maze_size - wall_thickness * 2, -half_maze_size, half_cube_size])
|
|
cube(wall_thickness);
|
|
|
|
translate([half_maze_size - wall_thickness, half_maze_size - wall_thickness * 2, half_cube_size])
|
|
cube(wall_thickness);
|
|
|
|
translate([half_maze_size - wall_thickness, half_maze_size - wall_thickness, -half_cube_size])
|
|
cube(wall_thickness);
|
|
|
|
translate([-half_maze_size + wall_thickness, half_maze_size - wall_thickness, -half_cube_size - wall_thickness])
|
|
cube(wall_thickness);
|
|
|
|
translate([-half_maze_size, -half_maze_size + wall_thickness, -half_cube_size - wall_thickness])
|
|
cube(wall_thickness);
|
|
|
|
translate([-half_maze_size, -half_maze_size, half_cube_size - wall_thickness])
|
|
cube(wall_thickness);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
cube_maze(maze_rows, cell_width, wall_thickness, inner_cube, travel_all);
|