4 ms·
Hi HN. Well, I wanted to make a 3D model and 3D print it, but I just didn't want to use OpenSCAD. So I ended up making a whole new 3D modeling library based on
by fogleman 6y ago
Hi HN.
Well, I wanted to make a 3D model and 3D print it, but I just didn't want to use OpenSCAD. So I ended up making a whole new 3D modeling library based on signed distance functions. I'm pretty happy with how it turned out so far, so I thought I would write a nice README and share it here.
It's certainly complete enough that you could try it out and make your own 3D models - let me know if you make anything interesting!
- sjkelly 6y agoThat's pretty cool. I see you are using marching cubes. How are you handling sharp geometry (I'm assuming previews use a finite difference for normals)? Also I see you are at formlabs. I'm sure you know of Matt Keeter's libfive :)
- fogleman 6y agoYes, I'm well aware of libfive! I'm not doing anything special for sharp geometry. For now you just need to use sufficient resolution until it looks "good enough." Normals are just based on the triangle normals.
- bhouston 6y agoTake the spatial derivative for the normals? Runga-kutta methods work wonders for that: https://en.m.wikipedia.org/wiki/Runge–Kutta_methods https://en.m.wikipedia.org/wiki/Runge–Kutta_methods That works well if they are true signed distance.
- user-the-name 6y agoSince you have a distance, you could fairly easily implement dual contouring, I think?
- andybak 6y agoOr Surface Nets. Nice compromise of speed and quality. Marching cubes needs a lot of resolution and it's imperfections are especially ugly my eyes. Maybe mesh resolution isn't a problem for 3D printing. But if 3D printing is the main goal why bother with a mesh? Just go straight to voxels that can be fed directly to the printer.
- user-the-name 6y agoThe printer does not use voxels, it uses G-codes, which are tool paths for the print head.
- andybak 6y agoOK. But a voxel representation has to be a closer match than a mesh. I guess overhang, solidity etc still need to be calculated and dealt with. Which is non-trivial. Is it that "mesh to G-code" libraries are more mature than "voxel to G-code"?
- tdotuos 6y agoTrue for FDM, but for SLA you have the potential rendering a direct slice of the SDF.
- stuntkite 6y agoThis is great. Thank you for making it! The api layout tells me you are a nice person.
- bhouston 6y agoSo elegant. Nice job!
- jmpeax 6y agoWhat a beautiful library and api! I don't 3D print, but I'll be studying your code as a master-class in how python should be done.
- blt 6y agoout of curiosity, why did you not want to use OpenSCAD?
- bvrmn 6y agoOpenSCAD is pretty rigorous regarding defining relative geometry. Like shifting origin and sketch on plane rotated 30° around X. It leads to unnecessary math to place objects.
- alpaca128 6y agoIt can be a bit cumbersome sometimes, but the only thing that really slows me down is the rendering performance. As soon as the detail level exceeds a certain range it basically becomes a bottleneck the size of a singularity. Just the last few days I spent hours creating an external preprocessor for a project so I can feed as little data as necessary into OpenSCAD. Luckily it kind of worked and got me from "process gets killed after 70 minutes" down to "finished rendering in 5 minutes". Still it's my favorite CAD software because the coding paradigm just feels so much more intuitive and simple than what FreeCAD and others do. I'm definitely going to try out this project, though; it looks very promising as well.
- sitkack 6y ago(to the channel), I am sure you know about it, but this [1] technique for making a big design a tree of smaller designs works ok. I feel like OpenSCAD is like 2 standard deviations away from perfection. Functions vs Modules and how clunky composition and application of operators over the object tree. It almost needs to be Datalog. Right now, it is a notch under SQL. [1] https://old.reddit.com/r/openscad/comments/lbq58y/my_approach_to_scripting_parts_and_converting/ https://old.reddit.com/r/openscad/comments/lbq58y/my_approac...
- alpaca128 6y agoThe problem in my case was that I wanted to combine a pattern with my objects that I precomputed using an external program because it contained a lot of curved surfaces. As I already knew OpenSCAD basically becomes unusable if you try to use a png image as heightmap I decided to instead generate a .scad file containing an array with precomputed coordinates, and then used that to build and extrude 2d polygons. This kind of works for the 3d preview, but the stl renderer was not happy regardless. It was basically the worst case for OpenSCAD. But still, the fact I could just auto-generate a text file and use it directly for building models is fantastic. With tools like FreeCAD I wouldn't even know where to start, here it was basically a case of "it just works" and with a few more minutes it can be combined with a bash script for batch rendering.
- tboerstad 6y agoLove the library! I did not know about signed distance functions, and I am just amazed of the complex shapes that can be made from simple primitives. Thank you!
- mfost 6y agoIf you want to go even deeper than that: https://www.youtube.com/watch?v=8--5LwHRhjk https://www.youtube.com/watch?v=8--5LwHRhjk