Browse Source

There was a long period of inactivity here

Alan Colon 7 năm trước cách đây
mục cha
commit
b02554935f
5 tập tin đã thay đổi với 244 bổ sung68 xóa
  1. 175 60
      DiceTower.scad
  2. 5 2
      config.scad
  3. 1 3
      pinch.scad
  4. 4 3
      tower.scad
  5. 59 0
      vine.scad

+ 175 - 60
DiceTower.scad

@@ -116,14 +116,18 @@ module stairs(radius, height, twists = 1, step_height = 1, step_depth = 1, overh
 
 module banister() {
   // Banister
-  intersection() {
-    translate([-tower_radius, 0, 0]) rotate([0,0,exit]) scale([-1, 1, 1]) {
-      difference() {
-        cylinder(r=tower_radius + 2, h=tower_radius, center=false);
-        translate([0,0,-1]) cylinder(r=tower_radius, h=tower_radius + 2, center=false);
+  y = 10;
+  {
+    intersection() {
+      translate([-tower_radius, 0, 0]) rotate([0,0,exit]) scale([-1, 1, 1]) {
+        difference() {
+          cylinder(r=tower_radius + 2, h=tower_radius+y, center=false);
+          translate([0,0,-1]) cylinder(r=tower_radius, h=tower_radius + 2+y, center=false);
+        }
       }
+      translate([0,0,-2]) cylinder(r=tower_radius - 2, h=tower_radius + 4 + y, center=false);
     }
-    translate([0,0,-2]) cylinder(r=tower_radius - 2, h=tower_radius + 4, center=false);
+    
   }
 }
 
@@ -146,7 +150,7 @@ module bottom_stairs_and_banister() {
     union() {
       banister();
     }
-    rotate([0,0,180]) translate([-10,0,0]) cube(size=[tower_radius + 10, tower_radius, bottom_stairs * 2], center=false);
+    rotate([0,0,180]) translate([-10,0,0]) cube(size=[tower_radius + 10, tower_radius, bottom_stairs * 3], center=false);
   }
 }
 
@@ -155,8 +159,23 @@ module double_stairs() {
     cylinder(r=tower_radius - brick_depth / 2, h=tower_height, center=false);
     union() {
       translate([0,0,bottom_stairs]) {
-        stairs(tower_radius, tower_height - bottom_stairs, step_height = step_height, step_depth = step_depth, twists = twists, underslope = underslope);
         rotate([0,0,180]) stairs(tower_radius, tower_height - bottom_stairs, step_height = step_height, step_depth = step_depth, twists = twists, underslope = underslope);
+        difference() {
+          stairs(tower_radius, tower_height - bottom_stairs, step_height = step_height, step_depth = step_depth, twists = twists, underslope = underslope);
+          //translate([0,0,-1]) cylinder(r=tower_radius, h=dungeon_extra + 1, center=false);
+
+          // Banister
+          translate([0,0,-1]) intersection() {
+            translate([-tower_radius, 0, 0]) rotate([0,0,exit]) scale([-1, 1, 1]) {
+              difference() {
+                cylinder(r=tower_radius * 2, h=tower_radius, center=false);
+                translate([0,0,-1]) cylinder(r=tower_radius, h=tower_radius + 2, center=false);
+              }
+            }
+            translate([0,0,-2]) cylinder(r=tower_radius - 2, h=tower_radius + 4, center=false);
+          }
+
+        }
       }
     }
   }
@@ -180,79 +199,175 @@ module dungeon_bars() {
   rotate([0,0,exit + dungeon_angle]) loop(max);
 }
 
+module generic_neg(angle, size, ratio) {
+  rotate([0,0,angle]) scale([1,1,ratio]) pinch(tower_radius + 10, size);
+}
+module generic_rim(angle, size, ratio, offset, border = 5) {
+  rotate([0,0,angle]) difference() {
+    translate([0,0,offset]) scale([1,1,ratio]) pinch(tower_radius + border, size + border);
+    scale([1,1,ratio]) pinch(tower_radius + 10, size);
+  }
+}
+
 module front_door_neg() {
-  scale([1,1,2]) rotate([90,0,exit]) cylinder(r=tower_radius / 2, h=100, center=false);
+  generic_neg(exit, tower_radius / 2, 2);
 }
 module front_door_rim() {
-  // Front door rim
-  intersection() {
-    cylinder(r=tower_radius + 10, h=60, center=false); 
-    difference() {
-      intersection() {
-        scale([1,1,2]) rotate([90,0,exit]) cylinder(r=tower_radius / 2 + 5, h=90, center=false);
-        cylinder(r=tower_radius + 10, h=tower_height, center=false);
-      }
-      // Front door
-      scale([1,1,2]) rotate([90,0,exit]) cylinder(r=tower_radius / 2, h=100, center=false);
-      // Inner tower
-      cylinder(r=tower_radius - groove, h=tower_height, center=true);        
-    }
-  }
+  generic_rim(exit, tower_radius / 2, 2, -4);
 }
 
 module dungeon_window_neg() {
-  rotate([0,0,dungeon_angle]) rotate([90,0,0]) translate([0,0,tower_radius]) cylinder(r=tower_radius, h=42, center=true);
+  generic_neg(dungeon_angle, tower_radius);
 }
 module dungeon_window_rim() {
-  rotate([0,0,dungeon_angle]) intersection() {
-    //cyl(tower_radius + 10, 50, center=false);
-    union() {
-      intersection() {
-        cylinder(r=tower_radius + 10, h=100, center=true);
-        linear_extrude(height=tower_height, center=false, convexity=10, twist=0) {
-          pie_slice(tower_radius + 10, 180 + 90 - 59.5, 180 + 90 + 59.5);
-        }
-        difference() {
-          rotate([90,0,0]) translate([0,0,tower_radius]) cylinder(r=tower_radius + 5, h=42, center=true);
-          difference() {
-            rotate([0,0,-dungeon_angle]) scale([1,0.9,1]) dungeon_window_neg();
-            linear_extrude(height=50, center=false) {
-              pie_slice(tower_radius + 10, 180 + 90 - 59.5, 180 + 90 - 59.5 + 360 * (3 / (tower_radius * PI)));
-              pie_slice(tower_radius + 10, 180 + 90 + 59.5, 180 + 90 + 59.5 - 360 * (3 / (tower_radius * PI)));
-            }
-          }
-        }
-      }
-      // intersection() {
-      //   linear_extrude(height=50, center=false) {
-      //     pie_slice(tower_radius + 10, 180 + 90 - 59.5, 180 + 90 - 59.5 + 360 * (3 / (tower_radius * PI)));
-      //     pie_slice(tower_radius + 10, 180 + 90 + 59.5, 180 + 90 + 59.5 - 360 * (3 / (tower_radius * PI)));
-      //   }
-      //   rotate([90,0,0]) translate([0,0,tower_radius]) cylinder(r=tower_radius + 5, h=42, center=true);
+  generic_rim(dungeon_angle, tower_radius, 1, 2);
+}
 
-      // }
-    }
+module window_neg(h, z) {
+  difference() {
+    translate([0,0,h]) rotate([0,0,exit+z])
+     generic_neg(90, 10, 1.5);
+    cylinder(r=tower_radius + 10, h);
   }
 }
 
-//*
-union() {
-  floor();
-  double_stairs();
+module window_rim(h, z) {
   difference() {
+    translate([0,0,h]) rotate([0,0,exit+z])
+      generic_rim(90, 10, 1.5, border=2);
+    cylinder(r=tower_radius + 10, h);
+  }
+  translate([0,0,h])
+  mirror([0,0,1])
+  rotate([0,0,z - 121.5])
+  linear_extrude(height=2, center=false, convexity=10, twist=0, scale=[.95,1]) {
+    pie_slice(tower_radius + 2, -15.5, 15.5 );
+  }
+}
+
+
+module detents(clearance = 0) {
+  rotate([0,0,45]) {
+    rotate([0,0,0]) translate([tower_radius - brick_depth / 2,0,0]) sphere(1.5 + clearance);
+    rotate([0,0,180]) translate([tower_radius - brick_depth / 2,0,0]) sphere(1.5 + clearance);
+    detent_r = pin_diameter / 2 + pin_clearance * 2;
+    translate([0,0,pin_height - detent_r]) sphere(detent_r + clearance);
+  }
+}
+//if (false)
+union() {
+  color("grey") floor();
+  color("grey") double_stairs();
+  color("grey") difference() {
     tower(tower_radius, tower_height);
     front_door_neg();
     dungeon_window_neg();
+    window_neg(100, 0);
+    window_neg(100, 180);
+    window_neg(75, 60);
+    window_neg(75, 240);
+    window_neg(50, 120);
+    window_neg(50, 300);
   }
-  intersection() {
-    tower(tower_radius + 5, 60);
+  color("grey") intersection() {
+    //tower(tower_radius + 5, 60);
+    difference() {
+      cylinder(r=tower_radius + 5, h=60, center=false);
+      cylinder(r=tower_radius + 5 - brick_depth, h=60, center=false);
+    }
     union() {
       front_door_rim();
       dungeon_window_rim();
     }
   }
-  dungeon_bars();
-  bottom_stairs_and_banister();
+  color("grey") intersection() {
+    
+    //tower(tower_radius + 2, tower_height);
+    difference() {
+      cylinder(r=tower_radius + 2, h=tower_height, center=false);
+      cylinder(r=tower_radius + 2 - brick_depth, h=tower_height, center=false);
+    }
+    union() {
+      window_rim(100, 0);
+      window_rim(100, 180);
+      window_rim(75, 60);
+      window_rim(75, 240);
+      window_rim(50, 120);
+      window_rim(50, 300);
+    }
+  }
+  color("grey") dungeon_bars();
+  color("grey") bottom_stairs_and_banister();
+
+  color("grey") cylinder(r=pin_diameter / 2, h=tower_height + pin_height, center=false);
+
+  color("red") translate([0,0,tower_height]) detents();
+}
+
+//$fn=25;
+//if (false) 
+color("grey") translate([0,0,tower_height]) {
+  radius = tower_radius + 5;
+  difference() {
+    union() {
+      translate([0, 0, 20]) sphere(7);
+      difference() {
+        union() {
+          tower(radius, 25);
+          difference() {
+            cylinder(r=radius - brick_depth / 2, h=2, center=false);
+            linear_extrude(height=5, center=true) {
+              pie_slice(tower_radius - brick_depth, -100, 45);
+            }
+            translate([0,0,2]) { // Grooves
+              rotate_extrude(convexity=10) {
+                translate([(radius - brick_depth / 2) * .25, 0, 0]) rotate([0,0,45]) square([groove,groove], center=true);
+                translate([(radius - brick_depth / 2) * .5, 0, 0]) rotate([0,0,45]) square([groove,groove], center=true);
+                translate([(radius - brick_depth / 2) * .75, 0, 0]) rotate([0,0,45]) square([groove,groove], center=true);
+              }
+              for (i=[1:5]) {
+                rotate([0,90+180,45+180 + 35 * i]) rotate([0,0,45]) linear_extrude(height=tower_radius, center=false, convexity=10, twist=0) {
+                    square(groove, groove, center=true);
+                }
+              }
+            }
+          }
+          rotate([0,0,-100]) translate([0, -2]) cube([radius - brick_depth / 2, 2, 20]);
+          cylinder(r=pin_diameter / 2 + pin_clearance * 2 + 2, h=20, center=false);
+          translate([0,0,25 - 3.5]) {
+            difference() {
+              rotate_extrude(convexity=10) {
+                translate([radius - brick_depth / 2, 0, 0]) rotate([0,0,45]) square([7,7]);
+              }
+            }
+          }
+        }
+        rampart_width = 15;
+        ramparts = 8;
+
+        translate([0,0,20]) {
+          for (z = [0:ramparts - 1]) {
+            rotate([0,0,360 / ramparts * z])
+            linear_extrude(height=20, center=false, convexity=10, twist=0) {
+              pie_slice(radius + 10, -rampart_width / 2, rampart_width / 2);
+            }
+          }
+        }
+      }
+      translate([0,0,2]) { // Lip
+        rotate([0,90+180,45+180]) rotate([0,0,45]) linear_extrude(height=tower_radius, center=false, convexity=10, twist=0) {
+            square(groove, groove, center=true);
+        }
+      }
+      translate([0,0,2]) { // Rim
+        rotate_extrude(convexity=10) {
+          translate([radius - .25, 0, 0]) circle(2, center=true);
+        }
+      }
+    }
+    color("red") detents(pin_clearance);
+    cylinder(r=pin_diameter / 2 + pin_clearance * 2, h=pin_height + pin_clearance, center=true);
+    rotate([0,0,-30]) translate([0,-.5, -1]) cube([10,2,10]);
+  }
 
-  cylinder(r=pin_diameter / 2, h=tower_height + pin_height, center=false);
 }

+ 5 - 2
config.scad

@@ -1,4 +1,4 @@
-draft=true;
+draft=false;
 
 tower_radius = 85 / 2;
 tower_height = 135;
@@ -19,4 +19,7 @@ pin_height=10;
 outer_pin_distance=37.2;
 outer_pin_diameter=4;
 outer_pin_angle=180;
-dungeon_angle=55;
+dungeon_angle=exit - 180;//55;
+dungeon_extra=step_height * 5;
+
+pin_clearance = 0.125;

+ 1 - 3
pinch.scad

@@ -4,10 +4,8 @@ module pinch(pinchRadius, circleRadius, centerWidth=0, round=false, center=true)
     zero = 0.0001;
     height=circleRadius*2;
     width = max(zero, centerWidth);
-    cube(1,1,1,center=true);
-
     hull() {
-        translate([0,0,center ? -circleRadius : 0]) {
+        rotate([0,0,-90]) translate([0,0,center ? -circleRadius : 0]) {
             intersection() {
                 translate([pinchRadius,0,circleRadius]) sphere(circleRadius);
                 difference() {

+ 4 - 3
tower.scad

@@ -27,7 +27,8 @@ module tower(radius, height) {
       
     }
     // Bottom groove
-    rotate_extrude() {
+    rotate_extrude()
+    {
       translate([radius * cos(start_deg), radius * sin(start_deg)]) {
         rotate([0, 0, 45]) {
           square(size=[groove, groove], center=true); 
@@ -49,12 +50,12 @@ module tower(radius, height) {
     }
   }
   difference() {
-    cylinder(r=radius, h=height, center=false);
+    color("silver") cylinder(r=radius, h=height, center=false);
     translate([0,0,-1]) {
       cylinder(r=radius - brick_depth, h=height + 2, center=false);
     }
     if (!draft) {
-      loop(rings + 1);
+      color("silver") loop(rings + 1);
     }
   }
 }

+ 59 - 0
vine.scad

@@ -0,0 +1,59 @@
+module vine(number, diameter, decrease, target, rateOfChange, chanceOfFork, chaos, chanceOfForkIncrease, seed = 1) {
+
+    function rnd(s) = rands(0,1,1,s)[0];
+
+    if (number > 0) {
+        union() {
+            polygon([
+                [-diameter / 2,0],
+                [(-diameter * decrease)/2, 3],
+                [(diameter * decrease)/2, 3],
+                [diameter / 2,0]
+            ]);
+            translate([0,3]) circle(diameter * decrease / 2);
+            //cylinder(3, diameter, diameter * decrease);
+            //translate([0,0,3]) sphere(diameter * decrease);
+        }
+        rndFork = rands(0,1,1,seed)[0];
+        fork = rndFork < chanceOfFork;
+        forks = fork ? [0,-45] : [0];
+        rndForks = rands(0,1,len(forks),rndFork);
+        rndForks2 = rands(0,1,len(forks),rndForks[len(rndForks) - 1]);
+        rndForks3 = rands(0,1,len(forks),rndForks[len(rndForks2) - 1]);
+        rndForks4 = rands(0,1,len(forks),rndForks[len(rndForks3) - 1]);
+         
+        for (i = [0:len(forks)-1]) {
+            turn = rateOfChange * rndForks[i] * sign(target) + forks[i] * rndForks2[i] + (rndForks3[i] - .5) * chaos;
+            translate([0,3,0]) rotate([0,0,turn])
+                vine(
+                    number - 1,
+                    diameter * decrease,
+                    decrease,
+                    target - turn,
+                    rateOfChange,
+                    //fork ? chanceOfFork / 2 : chanceOfFork,
+                    fork ? 0 : chanceOfFork + chanceOfForkIncrease,
+                    chaos,
+                    chanceOfForkIncrease,
+                    rndForks4[i]
+                );
+        }
+
+    }
+}
+
+/*
+$fn=16;
+linear_extrude(height = 10, center = true, convexity = 10)
+vine(
+    number = 20,
+    diameter = 3,
+    decrease = .9,
+    target = 0,
+    rateOfChange = 4,
+    chanceOfFork = 0,
+    chanceOfForkIncrease = .116,
+    chaos = 60,
+    seed=3
+);
+*/