/* * Cuatro - 3D Printable Game Pieces * * Copyright (c) 2025 Cuatro Project Contributors * Licensed under CC BY-NC-SA 4.0 International License * * This file defines modules for creating game pieces including tubes and boxes * with configurable dimensions for 3D printing. * * Print two copies, different colours. */ board_square_size_in_mm = 26; star_width = board_square_size_in_mm*0.4; default_height = board_square_size_in_mm*1.9; box_multiplier = 1.8; module tube_hole(offset_x=80, offset_y=0, height=default_height, fn, scale) { $fn=fn; difference() { translate([offset_x, offset_y, 0]) cylinder(r=star_width*scale,h=height); translate([offset_x, offset_y, -5]) cylinder(r=star_width/2, h=height+10); } } module tube_holes(row=1, fn=360, scale=1.0) { $fn=fn; row_offset=((star_width*2.5)+star_width/4)*row; tube_hole(fn=fn, offset_x=row_offset, offset_y=0, height=default_height, scale=scale); tube_hole(fn=fn, offset_x=row_offset, offset_y=(star_width*3)-star_width/15, height=default_height/2, scale=scale); } module tube(offset_x=80, offset_y=0, height=default_height, fn, scale=1.0) { $fn=fn; translate([offset_x, offset_y, 0]) cylinder(r=star_width*scale,h=height); } module tubes(row=1, fn=360, scale=1.0) { row_offset=((star_width*2.5)+star_width/4)*row; tube(fn=fn, offset_x=row_offset, offset_y=0, height=default_height, scale=scale); tube(fn=fn, offset_x=row_offset, offset_y=(star_width*3)-star_width/15, height=default_height/2, scale=scale); } module box(offset_x=80, offset_y=0, height=default_height) { translate([offset_x-(star_width/2), offset_y-(star_width/2), 0]) cube([star_width*box_multiplier, star_width*box_multiplier, height]); } module boxes(row=1) { row_offset=((star_width*2.5)+star_width/4)*row; box(offset_x=row_offset, offset_y=0, height=default_height); box(offset_x=row_offset, offset_y=(star_width*3)-star_width/15, height=default_height/2); } module box_holes(row=1) { row_offset=((star_width*2.5)+star_width/4)*row; box_hole(offset_x=row_offset, offset_y=0, height=default_height); box_hole(offset_x=row_offset, offset_y=(star_width*3)-star_width/15, height=default_height/2); } module box_hole(offset_x=80, offset_y=0, height=default_height, $fn) { difference() { translate([offset_x-(star_width/2), offset_y-(star_width/2), 0]) union() { cube([star_width*box_multiplier, star_width*box_multiplier, height]); //base(); }; translate([offset_x+(star_width/2.5), offset_y+(star_width/2.5), -5]) cylinder(r=star_width/2, h=height+10, $fn=360); } } module base() { rotate([0,0,45]) cylinder(h=default_height*0.1, r1=board_square_size_in_mm-0.2, r2=board_square_size_in_mm-2, $fn=4); } tube_holes(row=1, fn=360); tubes(row=2); boxes(row=3); box_holes(row=4);