mead-horn: note dependency on dotscad
[clinton/3d-models.git] / pacman-ghost / pacman-ghost.scad
CommitLineData
c9a67c51
CE
1//
2// Pacman Ghost
3// ------------
4//
5// Created by Joao Alves (jpralves@gmail.com)
9080b73a 6// Tea Light added by Clinton Ebadi <clinton@unknownlamer.org>
28182ec5 7// Pac Guy model by Fry Hyde
c9a67c51
CE
8// ------------------------------------------
9//
10// Parameters:
11
c9a67c51 12// Figure diameter
9080b73a
CE
13ghost_diameter = 50; // [25:5:100]
14pacguy_diameter = ghost_diameter * 1.5;
c9a67c51 15
9080b73a 16height = ghost_diameter*0.65;
c9a67c51
CE
17// Add keychain
18key_chain = 0; // [1:On, 0:Off]
19// Add LED hole
9080b73a
CE
20led_hole = 0; // [0:Off, 5:5mm, 8:8mm, 10:10mm]
21// Add tea light holder
22tea_light = true;
23
24// Render Ghost
25ghost = true;
26// Render Pac Guy
623e1176 27pacguy = false;
c9a67c51
CE
28
29// Detail
9080b73a
CE
30$fa=4; // [20:Low Res, 10:Normal Res, 4:Hi Res]
31
623e1176
CE
32// [Tea Light]
33base_diameter = 30;
34base_height = 16.2;
35bulb_diameter = 9;
267bb43f
CE
36// Built in sacrificial support layer
37tea_light_support = true;
38tea_light_support_thickness = 0.3;
623e1176 39
9080b73a
CE
40/* [Hidden] */
41$fs=0.1;
42
43module ghost() {
44 difference () {
45 union() {
46 cylinder(d = ghost_diameter, h = height);
47 translate([0, 0, height]) sphere(d = ghost_diameter);
48 if (key_chain == 1) {
49 translate([0, 0, height+ghost_diameter/2])
50 rotate([0, 90, 0])
51 rotate_extrude()
52 translate([4, 0, 0])
53 circle(r = 1.5);
54 }
55 }
56 translate([ghost_diameter/2, -ghost_diameter/4, height])
57 sphere(d = ghost_diameter/3.5);
58 translate([ghost_diameter/2, ghost_diameter/4, height])
59 sphere(d = ghost_diameter/3.5);
60 translate([0, 0, -0.1])
61 for(a = [0:11]) {
62 rotate([a/12*360,-90,0])
63 scale([1.5,1,1])
64 translate([0,0,ghost_diameter/12.5])
65 cylinder(ghost_diameter, 0,ghost_diameter/25*6.5, $fn=4);
66 }
67 }
68}
69
70module led_hole (led_d = led_hole, led_h = 0) {
71 // led_h==0 auto-sets height, openscad can't reference other
72 // arguments so this abomination arises
73 led_h = led_h ? led_h : height - (led_d+2);
74
75 union() {
76 cylinder(d = led_d+2, h = led_h);
77 translate([0, 0, led_h]) sphere(d = led_d+2);
78 }
79}
80
81module tea_light_base () {
9080b73a
CE
82 difference () {
83 union () {
84 cylinder (d = base_diameter + 1, h = base_height + 1);
623e1176 85 led_hole (led_d = bulb_diameter, led_h = base_height+8);
9080b73a 86 }
28182ec5
CE
87 // sacrificial support layer, subtracted since this will be
88 // subtracted from the ghost body
267bb43f
CE
89 if (tea_light_support) {
90 translate ([0, 0, base_height+(1 - tea_light_support_thickness)])
91 #cylinder (d=base_diameter+2, h=tea_light_support_thickness);
92 }
9080b73a 93 }
9080b73a
CE
94}
95
96module pacguy () {
97 // original model ghost_diameter is 30.464mm, scale to 1mm and then to
98 // final ghost_diameter. z is slightly smaller due to bottom being cut
99 // flat.
100 s = 1 / 30.464 * pacguy_diameter;
101 scale ([s, s, s]) translate ([0, 0, 28.742 / 2]) import ("PacGuy.stl", convexity=10);
102}
103
104module subtract_led () {
105 difference () {
106 children ();
107 if (led_hole > 0) led_hole ();
108 if (tea_light) tea_light_base ();
109 }
110}
111if (ghost) {
112 subtract_led () {
113 rotate ([0, 0, -90]) ghost ();
114 }
115}
116
117if (pacguy) {
118 translate ([ ghost ? (ghost_diameter + pacguy_diameter) / 2 + 10 : 0, 0, 0]) subtract_led () {
119 pacguy ();
120 }
121}