discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Metaballs come to BOSL2

AM
Adrian Mariano
Sat, Feb 15, 2025 1:54 PM

Someone recently remarked on the difficulty of creating organic forms in
OpenSCAD.  As it happens, a new feature in BOSL2 may make this easier.

https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad

Here are two examples that appear with code on the wikie.  A basic example:

[image: image.png]

A more elaborate example.  It takes 10s to preview or render on my
machine.

[image: image.png]

Someone recently remarked on the difficulty of creating organic forms in OpenSCAD. As it happens, a new feature in BOSL2 may make this easier. https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad Here are two examples that appear with code on the wikie. A basic example: [image: image.png] A more elaborate example. It takes 10s to preview or render on my machine. [image: image.png]
JB
Jon Bondy
Sat, Feb 15, 2025 2:03 PM

Very exciting!  Thank you!

On 2/15/2025 8:54 AM, Adrian Mariano via Discuss wrote:

Someone recently remarked on the difficulty of creating organic forms
in OpenSCAD.  As it happens, a new feature in BOSL2 may make this easier.

https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad

Here are two examples that appear with code on the wikie. A basic example:

image.png

A more elaborate example.  It takes 10s to preview or render on my
machine.

image.png


OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com

Very exciting!  Thank you! On 2/15/2025 8:54 AM, Adrian Mariano via Discuss wrote: > Someone recently remarked on the difficulty of creating organic forms > in OpenSCAD.  As it happens, a new feature in BOSL2 may make this easier. > > https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad > > Here are two examples that appear with code on the wikie. A basic example: > > image.png > > > A more elaborate example.  It takes 10s to preview or render on my > machine. > > image.png > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org -- This email has been checked for viruses by AVG antivirus software. www.avg.com
JW
Joe Weinpert
Sat, Feb 15, 2025 2:07 PM

As a wood carving artist, I have been looking for a way to create
organic/liquid STL's.
Metaballs is something I have been playing with for a few days.
I have a lot to learn ... a lot.
Attached is a pic of something I have been trying to create in this fashion.
Any pointers would be great.

[image: pic.jpg]
joe.weinpert@gmail.com
skidrowacademy.com

On Sat, Feb 15, 2025 at 8:55 AM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

Someone recently remarked on the difficulty of creating organic forms in
OpenSCAD.  As it happens, a new feature in BOSL2 may make this easier.

https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad

Here are two examples that appear with code on the wikie.  A basic example:

[image: image.png]

A more elaborate example.  It takes 10s to preview or render on my
machine.

[image: image.png]


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

As a wood carving artist, I have been looking for a way to create organic/liquid STL's. Metaballs is something I have been playing with for a few days. I have a lot to learn ... a lot. Attached is a pic of something I have been trying to create in this fashion. Any pointers would be great. [image: pic.jpg] joe.weinpert@gmail.com skidrowacademy.com On Sat, Feb 15, 2025 at 8:55 AM Adrian Mariano via Discuss < discuss@lists.openscad.org> wrote: > Someone recently remarked on the difficulty of creating organic forms in > OpenSCAD. As it happens, a new feature in BOSL2 may make this easier. > > https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad > > Here are two examples that appear with code on the wikie. A basic example: > > [image: image.png] > > > A more elaborate example. It takes 10s to preview or render on my > machine. > > [image: image.png] > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
AM
Adrian Mariano
Sat, Feb 15, 2025 2:36 PM

I'm really not at all an expert in metaballs---I should mention that the
feature was written by Alex Matulich.  It seems like to achieve something
like that you'd be best served by using isosurface rather than metaballs,
but I am not sure how you can build a function that has that shape.

On Sat, Feb 15, 2025 at 9:08 AM Joe Weinpert via Discuss <
discuss@lists.openscad.org> wrote:

As a wood carving artist, I have been looking for a way to create
organic/liquid STL's.
Metaballs is something I have been playing with for a few days.
I have a lot to learn ... a lot.
Attached is a pic of something I have been trying to create in this
fashion.
Any pointers would be great.

[image: pic.jpg]
joe.weinpert@gmail.com
skidrowacademy.com

On Sat, Feb 15, 2025 at 8:55 AM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

Someone recently remarked on the difficulty of creating organic forms in
OpenSCAD.  As it happens, a new feature in BOSL2 may make this easier.

https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad

Here are two examples that appear with code on the wikie.  A basic
example:

[image: image.png]

A more elaborate example.  It takes 10s to preview or render on my
machine.

[image: image.png]


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I'm really not at all an expert in metaballs---I should mention that the feature was written by Alex Matulich. It seems like to achieve something like that you'd be best served by using isosurface rather than metaballs, but I am not sure how you can build a function that has that shape. On Sat, Feb 15, 2025 at 9:08 AM Joe Weinpert via Discuss < discuss@lists.openscad.org> wrote: > As a wood carving artist, I have been looking for a way to create > organic/liquid STL's. > Metaballs is something I have been playing with for a few days. > I have a lot to learn ... a lot. > Attached is a pic of something I have been trying to create in this > fashion. > Any pointers would be great. > > [image: pic.jpg] > joe.weinpert@gmail.com > skidrowacademy.com > > > > On Sat, Feb 15, 2025 at 8:55 AM Adrian Mariano via Discuss < > discuss@lists.openscad.org> wrote: > >> Someone recently remarked on the difficulty of creating organic forms in >> OpenSCAD. As it happens, a new feature in BOSL2 may make this easier. >> >> https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad >> >> Here are two examples that appear with code on the wikie. A basic >> example: >> >> [image: image.png] >> >> >> A more elaborate example. It takes 10s to preview or render on my >> machine. >> >> [image: image.png] >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
SP
Sanjeev Prabhakar
Sat, Feb 15, 2025 4:05 PM

Looks great
Can anyone share the logic for producing these shapes. It would be
interesting to know.

On Sat, 15 Feb, 2025, 7:25 pm Adrian Mariano via Discuss, <
discuss@lists.openscad.org> wrote:

Someone recently remarked on the difficulty of creating organic forms in
OpenSCAD.  As it happens, a new feature in BOSL2 may make this easier.

https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad

Here are two examples that appear with code on the wikie.  A basic example:

[image: image.png]

A more elaborate example.  It takes 10s to preview or render on my
machine.

[image: image.png]


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Looks great Can anyone share the logic for producing these shapes. It would be interesting to know. On Sat, 15 Feb, 2025, 7:25 pm Adrian Mariano via Discuss, < discuss@lists.openscad.org> wrote: > Someone recently remarked on the difficulty of creating organic forms in > OpenSCAD. As it happens, a new feature in BOSL2 may make this easier. > > https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad > > Here are two examples that appear with code on the wikie. A basic example: > > [image: image.png] > > > A more elaborate example. It takes 10s to preview or render on my > machine. > > [image: image.png] > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
AM
Adrian Mariano
Sat, Feb 15, 2025 4:11 PM

A brief intro appears here:  https://en.wikipedia.org/wiki/Metaballs and
google can turn up various pages on the topic.

On Sat, Feb 15, 2025 at 11:05 AM Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

Looks great
Can anyone share the logic for producing these shapes. It would be
interesting to know.

On Sat, 15 Feb, 2025, 7:25 pm Adrian Mariano via Discuss, <
discuss@lists.openscad.org> wrote:

Someone recently remarked on the difficulty of creating organic forms in
OpenSCAD.  As it happens, a new feature in BOSL2 may make this easier.

https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad

Here are two examples that appear with code on the wikie.  A basic
example:

[image: image.png]

A more elaborate example.  It takes 10s to preview or render on my
machine.

[image: image.png]


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

A brief intro appears here: https://en.wikipedia.org/wiki/Metaballs and google can turn up various pages on the topic. On Sat, Feb 15, 2025 at 11:05 AM Sanjeev Prabhakar <sprabhakar2006@gmail.com> wrote: > Looks great > Can anyone share the logic for producing these shapes. It would be > interesting to know. > > On Sat, 15 Feb, 2025, 7:25 pm Adrian Mariano via Discuss, < > discuss@lists.openscad.org> wrote: > >> Someone recently remarked on the difficulty of creating organic forms in >> OpenSCAD. As it happens, a new feature in BOSL2 may make this easier. >> >> https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad >> >> Here are two examples that appear with code on the wikie. A basic >> example: >> >> [image: image.png] >> >> >> A more elaborate example. It takes 10s to preview or render on my >> machine. >> >> [image: image.png] >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >
TS
Tim Schmidt
Mon, Feb 17, 2025 12:47 AM

This idea looked so neat, and the render times so rough, that I added a
MetaBall object and from_metaballs function to
https://github.com/timschmidt/csgrs based on
https://crates.io/crates/fast-surface-nets

metaballs are available immediately in release 0.15.1 of csgrs here:
https://crates.io/crates/csgrs

Here's an example:

// Alias the library’s generic CSG type with empty metadata:type CSG =
csgrs::csg::CSG<()>;

// Metaballs https://en.wikipedia.org/wiki/Metaballsuse
csgrs::csg::MetaBall;let balls = vec![
MetaBall::new(Point3::new(0.0, 0.0, 0.0), 1.0),
MetaBall::new(Point3::new(1.5, 0.0, 0.0), 1.0),];
let resolution = (60, 60, 60);let iso_value = 1.0;let padding = 1.0;
let metaball_csg = CSG::from_metaballs(
&balls,
resolution,
iso_value,
padding,);

// save to STL
let stl_data = metaball_csg.to_stl_binary("my_metaballs").unwrap();
std::fs::write("stl/metaballs.stl", stl_data)
.expect("Failed to write metaballs.stl");

On Sat, Feb 15, 2025 at 11:12 AM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

A brief intro appears here:  https://en.wikipedia.org/wiki/Metaballs and
google can turn up various pages on the topic.

On Sat, Feb 15, 2025 at 11:05 AM Sanjeev Prabhakar <
sprabhakar2006@gmail.com> wrote:

Looks great
Can anyone share the logic for producing these shapes. It would be
interesting to know.

On Sat, 15 Feb, 2025, 7:25 pm Adrian Mariano via Discuss, <
discuss@lists.openscad.org> wrote:

Someone recently remarked on the difficulty of creating organic forms in
OpenSCAD.  As it happens, a new feature in BOSL2 may make this easier.

https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad

Here are two examples that appear with code on the wikie.  A basic
example:

[image: image.png]

A more elaborate example.  It takes 10s to preview or render on my
machine.

[image: image.png]


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

--
Timothy Schmidt
(517) 292-4030
timschmidt@gmail.com
https://wiki.replimat.org

This idea looked so neat, and the render times so rough, that I added a MetaBall object and from_metaballs function to https://github.com/timschmidt/csgrs based on https://crates.io/crates/fast-surface-nets metaballs are available immediately in release 0.15.1 of csgrs here: https://crates.io/crates/csgrs Here's an example: // Alias the library’s generic CSG type with empty metadata:type CSG = csgrs::csg::CSG<()>; // Metaballs https://en.wikipedia.org/wiki/Metaballsuse csgrs::csg::MetaBall;let balls = vec![ MetaBall::new(Point3::new(0.0, 0.0, 0.0), 1.0), MetaBall::new(Point3::new(1.5, 0.0, 0.0), 1.0),]; let resolution = (60, 60, 60);let iso_value = 1.0;let padding = 1.0; let metaball_csg = CSG::from_metaballs( &balls, resolution, iso_value, padding,); // save to STL let stl_data = metaball_csg.to_stl_binary("my_metaballs").unwrap(); std::fs::write("stl/metaballs.stl", stl_data) .expect("Failed to write metaballs.stl"); On Sat, Feb 15, 2025 at 11:12 AM Adrian Mariano via Discuss < discuss@lists.openscad.org> wrote: > A brief intro appears here: https://en.wikipedia.org/wiki/Metaballs and > google can turn up various pages on the topic. > > On Sat, Feb 15, 2025 at 11:05 AM Sanjeev Prabhakar < > sprabhakar2006@gmail.com> wrote: > >> Looks great >> Can anyone share the logic for producing these shapes. It would be >> interesting to know. >> >> On Sat, 15 Feb, 2025, 7:25 pm Adrian Mariano via Discuss, < >> discuss@lists.openscad.org> wrote: >> >>> Someone recently remarked on the difficulty of creating organic forms in >>> OpenSCAD. As it happens, a new feature in BOSL2 may make this easier. >>> >>> https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad >>> >>> Here are two examples that appear with code on the wikie. A basic >>> example: >>> >>> [image: image.png] >>> >>> >>> A more elaborate example. It takes 10s to preview or render on my >>> machine. >>> >>> [image: image.png] >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > -- Timothy Schmidt (517) 292-4030 timschmidt@gmail.com https://wiki.replimat.org
JB
Jordan Brown
Mon, Feb 17, 2025 3:32 AM

Just for fun, I took a quick stab at duplicating Ed Catmull's Dumbo the
Elephant model
https://commons.wikimedia.org/wiki/File:Bicubic_Patches.png.  I didn't
refine it all that far, but the results are promising.

Original:
File:Bicubic Patches.png

My attempt:

Nothing to get excited about, but a lot closer than the last time I
tried to do it with Bézier patches, for a lot less effort.

Here's the program:

include <BOSL2/std.scad>
include <BOSL2/isosurface.scad>
legD1 = 12;
legD2 = 6;
spec = [
// legs
fwd(8)*left(10), mb_cyl(d1=legD1, d2=legD2, h=20),
fwd(8)*right(10), mb_cyl(d1=legD1, d2=legD2, h=20),
back(8)*left(10), mb_cyl(d1=legD1, d2=legD2, h=20),
back(8)*right(10), mb_cyl(d1=legD1, d2=legD2, h=20),
up(20)*yrot(90), mb_capsule(d=25,h=40, influence=0.5),  // body
right(20)*up(25)*yrot(-20), mb_capsule(r=7, h = 25, influence=0.1),  // head
right(23)*up(10)*yrot(20), mb_cyl(d1 = 3, d2=6, h = 15, influence=0.2),    // trunk
// ears
right(20)*up(29)*fwd(11)*yrot(80)*scale([1.7,1,1]), mb_disk(r=5,h=5, influence=0.1),
right(20)*up(29)*back(11)*yrot(80)*scale([1.7,1,1]), mb_disk(r=5,h=5, influence=0.1),
// tusks
right(25)*up(13)*fwd(5)*yrot(135), mb_capsule(r=1, h = 10, influence=0.1),
right(25)*up(13)*back(5)*yrot(135), mb_capsule(r=1, h = 10, influence=0.1),
];
bb = [[-30,-20,-15], [30,20,40]];
//#translate(bb[0]) cube(bb[1]-bb[0]);
metaballs(spec, voxel_size=0.5, bounding_box=bb);

Just for fun, I took a quick stab at duplicating Ed Catmull's Dumbo the Elephant model <https://commons.wikimedia.org/wiki/File:Bicubic_Patches.png>.  I didn't refine it all that far, but the results are promising. Original: File:Bicubic Patches.png My attempt: Nothing to get excited about, but a lot closer than the last time I tried to do it with Bézier patches, for a lot less effort. Here's the program: include <BOSL2/std.scad> include <BOSL2/isosurface.scad> legD1 = 12; legD2 = 6; spec = [ // legs fwd(8)*left(10), mb_cyl(d1=legD1, d2=legD2, h=20), fwd(8)*right(10), mb_cyl(d1=legD1, d2=legD2, h=20), back(8)*left(10), mb_cyl(d1=legD1, d2=legD2, h=20), back(8)*right(10), mb_cyl(d1=legD1, d2=legD2, h=20), up(20)*yrot(90), mb_capsule(d=25,h=40, influence=0.5), // body right(20)*up(25)*yrot(-20), mb_capsule(r=7, h = 25, influence=0.1), // head right(23)*up(10)*yrot(20), mb_cyl(d1 = 3, d2=6, h = 15, influence=0.2), // trunk // ears right(20)*up(29)*fwd(11)*yrot(80)*scale([1.7,1,1]), mb_disk(r=5,h=5, influence=0.1), right(20)*up(29)*back(11)*yrot(80)*scale([1.7,1,1]), mb_disk(r=5,h=5, influence=0.1), // tusks right(25)*up(13)*fwd(5)*yrot(135), mb_capsule(r=1, h = 10, influence=0.1), right(25)*up(13)*back(5)*yrot(135), mb_capsule(r=1, h = 10, influence=0.1), ]; bb = [[-30,-20,-15], [30,20,40]]; //#translate(bb[0]) cube(bb[1]-bb[0]); metaballs(spec, voxel_size=0.5, bounding_box=bb);
JD
John David
Mon, Feb 17, 2025 3:53 AM

@Joe Weinpert joe.weinpert@gmail.com
, interesting.  I have a metal and stone sculpture I dreamed up years ago
that I could model with this.  I definitely want to keep up on your
progress.  Please send us pictures of anything you realize in wood ;-)

On Sun, Feb 16, 2025 at 10:32 PM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

Just for fun, I took a quick stab at duplicating Ed Catmull's Dumbo the
Elephant model
https://commons.wikimedia.org/wiki/File:Bicubic_Patches.png.  I didn't
refine it all that far, but the results are promising.

Original:
[image: File:Bicubic Patches.png]

My attempt:

Nothing to get excited about, but a lot closer than the last time I tried
to do it with Bézier patches, for a lot less effort.

Here's the program:

include <BOSL2/std.scad>
include <BOSL2/isosurface.scad>
legD1 = 12;
legD2 = 6;
spec = [
// legs
fwd(8)*left(10), mb_cyl(d1=legD1, d2=legD2, h=20),
fwd(8)*right(10), mb_cyl(d1=legD1, d2=legD2, h=20),
back(8)*left(10), mb_cyl(d1=legD1, d2=legD2, h=20),
back(8)*right(10), mb_cyl(d1=legD1, d2=legD2, h=20),
up(20)*yrot(90), mb_capsule(d=25,h=40, influence=0.5),  // body
right(20)*up(25)*yrot(-20), mb_capsule(r=7, h = 25, influence=0.1),  // head
right(23)*up(10)*yrot(20), mb_cyl(d1 = 3, d2=6, h = 15, influence=0.2),    // trunk
// ears
right(20)*up(29)*fwd(11)*yrot(80)*scale([1.7,1,1]), mb_disk(r=5,h=5, influence=0.1),
right(20)*up(29)*back(11)*yrot(80)*scale([1.7,1,1]), mb_disk(r=5,h=5, influence=0.1),
// tusks
right(25)*up(13)*fwd(5)*yrot(135), mb_capsule(r=1, h = 10, influence=0.1),
right(25)*up(13)*back(5)*yrot(135), mb_capsule(r=1, h = 10, influence=0.1),
];
bb = [[-30,-20,-15], [30,20,40]];
//#translate(bb[0]) cube(bb[1]-bb[0]);
metaballs(spec, voxel_size=0.5, bounding_box=bb);


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

@Joe Weinpert <joe.weinpert@gmail.com> , interesting. I have a metal and stone sculpture I dreamed up years ago that I could model with this. I definitely want to keep up on your progress. Please send us pictures of anything you realize in wood ;-) On Sun, Feb 16, 2025 at 10:32 PM Jordan Brown via Discuss < discuss@lists.openscad.org> wrote: > Just for fun, I took a quick stab at duplicating Ed Catmull's Dumbo the > Elephant model > <https://commons.wikimedia.org/wiki/File:Bicubic_Patches.png>. I didn't > refine it all that far, but the results are promising. > > Original: > [image: File:Bicubic Patches.png] > > > My attempt: > > > Nothing to get excited about, but a lot closer than the last time I tried > to do it with Bézier patches, for a lot less effort. > > Here's the program: > > include <BOSL2/std.scad> > include <BOSL2/isosurface.scad> > legD1 = 12; > legD2 = 6; > spec = [ > // legs > fwd(8)*left(10), mb_cyl(d1=legD1, d2=legD2, h=20), > fwd(8)*right(10), mb_cyl(d1=legD1, d2=legD2, h=20), > back(8)*left(10), mb_cyl(d1=legD1, d2=legD2, h=20), > back(8)*right(10), mb_cyl(d1=legD1, d2=legD2, h=20), > up(20)*yrot(90), mb_capsule(d=25,h=40, influence=0.5), // body > right(20)*up(25)*yrot(-20), mb_capsule(r=7, h = 25, influence=0.1), // head > right(23)*up(10)*yrot(20), mb_cyl(d1 = 3, d2=6, h = 15, influence=0.2), // trunk > // ears > right(20)*up(29)*fwd(11)*yrot(80)*scale([1.7,1,1]), mb_disk(r=5,h=5, influence=0.1), > right(20)*up(29)*back(11)*yrot(80)*scale([1.7,1,1]), mb_disk(r=5,h=5, influence=0.1), > // tusks > right(25)*up(13)*fwd(5)*yrot(135), mb_capsule(r=1, h = 10, influence=0.1), > right(25)*up(13)*back(5)*yrot(135), mb_capsule(r=1, h = 10, influence=0.1), > ]; > bb = [[-30,-20,-15], [30,20,40]]; > //#translate(bb[0]) cube(bb[1]-bb[0]); > metaballs(spec, voxel_size=0.5, bounding_box=bb); > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >