21c55be3d2bcfc4028d2fef68e819fac9c8ed493
[clinton/3d-models.git] / ble arcade controller / arcade-box.scad
1 // arcade controller thing
2 // Copyright (c) 2017 Clinton Ebadi <clinton@unknownlamer.org>
3 // GPLv3 or (at your option) any later version
4 // .. insert license text here ...
5
6 use <obiscad/bcube.scad>
7 use <obiscad/attach.scad>
8
9 // PREVIEW
10 union () {
11 rotate ([-10, 0, 0]) translate ([0, 0, box_h+20]) panel ();
12 case ();
13 }
14
15
16 // CONFIGURATION
17
18 panel_w = 250;
19 panel_h = 120;
20
21 box_h = 80; // fixme: box_d.
22 box_wall = 2;
23 base_h = 5; //fixme: thickness?
24
25 // bcube parameters, clean up
26 cr = box_wall*2;
27 cres = 0;
28
29 $button_d = 28;
30 js_width = 85;
31 js_height = 40;
32
33 // PANEL COMPONENTS
34
35 module button (bezel = $button_d+4) {
36 circle (d=$button_d);
37 %circle(d=bezel);
38 }
39
40
41 module joystick () {
42 bolt_d = 8;
43 center_hole_d = 24;
44
45 for (x = [-js_width/2, js_width/2], y = [-js_height/2, js_height/2]) {
46 translate ([x, y, 0]) circle (d=bolt_d); // need slot instead
47 }
48 circle (d=center_hole_d);
49
50 %square ([js_width, js_height], center=true); // not right...
51 }
52
53
54 // CASE
55
56 module case_base (h=base_h) {
57 bcube([panel_w, panel_h, h], cr, cres);
58 }
59
60 module case_walls () {
61 difference() {
62 bcube([panel_w, panel_h, box_h-base_h], cr, cres);
63 bcube([panel_w-box_wall, panel_h-box_wall, box_h], cr, cres);
64 }
65 }
66
67 module case () {
68 case_base ();
69 translate ([0, 0, (box_h)/2]) case_walls ();
70 }
71
72
73 // PANEL
74
75 module panel () {
76 difference () {
77 case_base ();
78 linear_extrude (base_h*2,center=true) panel_layout ();
79 }
80 }
81
82 module panel_attach (position, angle=0) {
83 x = position[0];
84 y = position[1];
85 c1 = [ [x, y, base_h/2], [0,0,1], angle ]; //[0, 0, h];
86 a1 = [ [0,0, 0], [0,0,0], 0 ];
87 // connector (c1);
88 attach (c1, a1) children ();
89 }
90
91 // panel layout inspired by the Neo Geo layout
92 module panel_layout () {
93 translate ([-panel_w/2 + 40, 0, 0]) {
94 panel_attach ([0, 0], 90) joystick ();
95
96 // p1, coin (floating off in the distance...)
97 union () {
98 $button_d=18;
99 for (x = [0, $button_d+10]) {
100 panel_attach ([x, 90]) button ();
101 panel_attach ([x, 90]) button ();
102 }
103 }
104
105 // a, b, c, d
106 union () {
107 buttons_offset = 60;
108 panel_attach ([buttons_offset, 0]) button ();
109 for (i = [ 1 : 3 ]) {
110 panel_attach ([i*($button_d+10)+buttons_offset-5, 30]) button ();
111 }
112 }
113 }
114 }