aboutsummaryrefslogtreecommitdiff
path: root/src/piecepack.scad
blob: 9c830aedbb2bc937ae42584db540dabe87959813 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
module tile(suite,value) {
    union() {
        difference(){
            translate([0,0,0.4]) cube([50,50,4.6]);
            if (value == "ace") {
                translate([0,0,4]) linear_extrude(height=2) 
                    import(str("../graphics/",suite,".dxf"));
            } else if (value != "null") {
                translate([0,0,4]) linear_extrude(height=2) 
                    import(str("../graphics/",value,".dxf"));
            }
            translate([0,35,4]) linear_extrude(height=2) scale(0.3) import(str("../graphics/",suite,".dxf"));
            }
        cube([24.5,24.5,1]);
        translate([25.5,0,0]) cube([24.5,24.5,1]);
        translate([0,25.5,0]) cube([24.5,24.5,1]);
        translate([25.5,25.5,0]) cube([24.5,24.5,1]);
    }
}

module coin(suite,value) {
    difference() {
        cylinder(r=10, h=3);
        translate([0,0,2]) linear_extrude(height=1.5) scale(0.4) 
            translate([-25,-25,0])
            import(str("../graphics/",suite,".dxf"),center=true);
        if (value != "null") {
            translate([0,0,1]) rotate([0,180,0]) linear_extrude(height=1.5) scale(0.4)
                translate([-25,-25,0])
                import(str("../graphics/",value,".dxf"),center=true);
        }
        translate([0,10,3]) rotate([90,0,0]) cylinder(r=0.8, h=2);
        translate([0,10,0]) rotate([90,0,0]) cylinder(r=0.8, h=2);
    }
}

module die(suite,s) {
    difference() {
        intersection() {
            cube(s);
            translate([s/2,s/2,s/2]) sphere(r=s*0.79);
        }
        translate([0,0,s-1]) linear_extrude(height=1.5) scale(s*0.02)
            import(str("../graphics/",suite,".dxf"));
        translate([1,0,0]) rotate([0,-90,0])
            linear_extrude(height=1.5) scale(s*0.02)
            import("../graphics/2.dxf");
        translate([s-1,0,s]) rotate([0,90,0])
            linear_extrude(height=1.5) scale(s*0.02)
            import("../graphics/5.dxf");
        translate([0,1,0]) rotate([90,0,0])
            linear_extrude(height=1.5) scale(s*0.02)
            import("../graphics/3.dxf");
        translate([0,s-1,s]) rotate([-90,0,0])
            linear_extrude(height=1.5) scale(s*0.02)
            import("../graphics/4.dxf");
    }
}

module suite_die(suites,s) {
    difference() {
        intersection() {
            cube(s);
            translate([s/2,s/2,s/2]) sphere(r=s*0.79);
        }
        translate([1,0,0]) rotate([0,-90,0])
            linear_extrude(height=1.5) scale(s*0.02)
            import(str("../graphics/",suites[0],".dxf"));
        translate([s-1,0,s]) rotate([0,90,0])
            linear_extrude(height=1.5) scale(s*0.02)
            import(str("../graphics/",suites[1],".dxf"));
        translate([0,1,0]) rotate([90,0,0])
            linear_extrude(height=1.5) scale(s*0.02)
            import(str("../graphics/",suites[2],".dxf"));
        translate([0,s-1,s]) rotate([-90,0,0])
            linear_extrude(height=1.5) scale(s*0.02)
            import(str("../graphics/",suites[3],".dxf"));
        if ( len(suites) >= 5) {
            translate([0,0,s-1]) linear_extrude(height=1.5) scale(s*0.02)
                import(str("../graphics/",suites[4],".dxf"));
        } else {
            translate([0,0,s-1]) linear_extrude(height=1.5) scale(s*0.02)
                import("../graphics/ace.dxf");
        }
        if ( len(suites) >= 6) {
            translate([0,0,-0.5]) linear_extrude(height=1.5) scale(s*0.02)
                import(str("../graphics/",suites[5],".dxf"));
        }
    }
}

module pawn(suite) {
    difference() {
        cylinder(r=8, h=22);
    translate([-8,-8,21]) linear_extrude(height=1.5) scale(0.32)
        import(str("../graphics/",suite,".dxf"),center=true);
    }
}

module saucer(suite) {
    difference() {
        cylinder(r=12, h=5);
        translate([0,0,3]) cylinder(r=9, h=3);
        translate([0,12,-1]) cylinder(r=2, h=7);
    translate([-8,-8,2]) linear_extrude(height=1.5) scale(0.32)
        import(str("../graphics/",suite,".dxf"),center=true);
    }
}

module plain_pyramid(w,h,z) {
    polyhedron(points=[[-w/2,-w/2,z], [w/2,-w/2,z], 
                       [w/2,w/2,z],   [-w/2,w/2,z], [z,z,h]],
        triangles=[[0,1,2], [0,2,3], 
            [0,4,1], [1,4,2], [2,4,3], [3,4,0]]);
}

module pyramid(w,h,suite,value) {
    difference() {
        plain_pyramid(w,h,0);
        plain_pyramid(w-4,h-4,-0.01);
        translate([0,0,h]) cube(7, center=true);
        if ( suite != "null") {
            translate([0,-w/2+1,0]) rotate([atan(h/(w/2)),0,0]) linear_extrude(height=2) 
                scale(0.9*w/50) translate([-25,0,0]) import(str("../graphics/",suite,".dxf"));
        }
        if ( value != "null") {
            translate([0,w/2-1,0]) 
            rotate([-atan(h/(w/2)),0,0]) rotate([0,0,180]) linear_extrude(height=2) 
                scale(0.9*w/50) translate([-25,0,0]) import(str("../graphics/",value,".dxf"));
        }
    }
}