First pass at attachments support.

This commit is contained in:
Revar Desmera
2019-04-16 19:16:50 -07:00
parent 96739c3ea0
commit 6f342f450f
10 changed files with 861 additions and 174 deletions

21
examples/attachments.scad Normal file
View File

@@ -0,0 +1,21 @@
include <BOSL/constants.scad>
include <BOSL/transforms.scad>
include <BOSL/primitives.scad>
include <BOSL/shapes.scad>
include <BOSL/debug.scad>
cuboid([60,40,40], fillet=5, edges=EDGES_Z_ALL, align="bottom") {
attach("top") rounded_prismoid([60,40],[20,20], h=50, r1=5, r2=10) {
attach("top") cylinder(d=20, h=30) {
attach("top") cylinder(d1=50, d2=30, h=12);
}
for (a = ["front", "back", "left", "right"]) {
attach(a) cylinder(d1=14, d2=5, h=20) {
attach("top", "left", overlap=5) prismoid([30,20], [20,20], h=10, shift=[-7,0]);
}
}
}
}
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -0,0 +1,9 @@
include <BOSL/constants.scad>
include <BOSL/primitives.scad>
include <BOSL/debug.scad>
cylinder(h=30, d1=50, d2=30) show_connectors("cylinder");
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -0,0 +1,42 @@
include <BOSL/constants.scad>
include <BOSL/transforms.scad>
include <BOSL/primitives.scad>
include <BOSL/beziers.scad>
module leaf(s) {
path = [
[0,0], [1.5,-1],
[2,1], [0,3], [-2,1],
[-1.5,-1], [0,0]
];
xrot(90)
linear_extrude_bezier(
scale_points(path, [s,s]/2),
height=0.02
);
}
module branches(minsize){
if($parent_size2.x>minsize) {
attach("top")
zrot(gaussian_rand(90,10))
zring(n=floor(log_rand(2,5,4)))
zrot(gaussian_rand(0,5))
yrot(gaussian_rand(30,5))
let(
sc = gaussian_rand(0.7,0.05),
s1 = $parent_size.z*sc,
s2 = $parent_size2.x
)
cylinder(d1=s2, d2=s2*sc, l=s1)
branches(minsize);
} else {
recolor("springgreen")
attach("top") zrot(90)
leaf(gaussian_rand(100,5));
}
}
recolor("lightgray") cylinder(d1=300, d2=250, l=1500) branches(5);
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

View File

@@ -0,0 +1,9 @@
include <BOSL/constants.scad>
include <BOSL/shapes.scad>
include <BOSL/debug.scad>
prismoid([60,40], [30,20], h=40) show_connectors();
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap

18
examples/tagged_diff.scad Normal file
View File

@@ -0,0 +1,18 @@
include <BOSL/constants.scad>
include <BOSL/transforms.scad>
include <BOSL/primitives.scad>
include <BOSL/shapes.scad>
diff("hole", "body pole")
sphere(d=100, $tags="body") {
zcyl(d=55, h=100, $tags="pole"); // attach() not needed for center-to-center.
tags("hole") {
xcyl(d=55, h=101);
ycyl(d=55, h=101);
}
zcyl(d=15, h=140, $tags="axle");
}
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap