Bicubic Surfaces

And finally, the kitchen sink!

After a whole bunch of the basic primitives, if you consider the SuperShape/Formula a “basic”, I have come to the bicubic surfaces.  I originally wrote the code for this in OpenScad.  Translating it over to work in FabuCad was pretty simple, and largely involves eliminating code, and merging things back together.

If you look at the example, it’s pretty straight forward to use.  In this particular case, I’m using the Bezier basis by default.  You could just as easily substitute the Catmull-Rom or the Hermite (they’re both built in).  It’s not quite splines or nurbs, but those will come along soon enough.  The intention here is that you can pretty easily create and play with all sorts of forms of things, and quickly see them rendered and print out samples on your 3D printer.

This is reasonably fast code.  In the picture, there are 16 of these bezier surfaces, and the rendering time is a matter of seconds, not minutes or hours.  And of course creating the .stl from there is just a menu click away.

…and even if you do 100 of them,  with a facet count of 1600 apiece, it still only takes about 20 seconds to render.

Well, that’s it.

Enough functions for phase I of this thing.  I guess it’s time to write up some documentation and actually release it.

Advertisements

Solid Blobs

I must admit, although it is very exciting to think about not having to slice a .stl file for printing, and sending high level commands to a printer directly, we’re not there as yet.

The reality is, today, every printer consumes .stl files.  So, if I want to share and print metaball based objects, I have to go the extra step of creating surfaces for those softly defined entities.  Well, If you’ve done any metaball/blob programming, you might realize that they are a computational nightmare, if you actually want to generate an actual 2-manifold surface for them.  If you want to render them in real time, no problem.  These days graphics hardware will make short work of them.  Mainly because you can use ray casting and determine on a per pixel basis what color something should be.

Problem is, I need a mesh, so it’s not quite good enough to simply cast all those rays.  Of course I could cast rays, and create a mesh made up of single ‘pixel’ sized rectangles, but that’s not very satisfying, and will take quite a long time.  I could take those cubes I created and do something with those…

I came up with another idea, and right now I’m trying to figure out if it’s a novel approach.  It’s kind of a hybrid of approaches used for typical graphical rendering, but with a bent towards meshing.

At any rate, using this approach, I can render these metaball structures in relative realtime, and create 2-manifold surfaces in the bargain.  I think that’s pretty nifty.  At the same time, I added a simple “blobs()” function to the arsenal, so everyone can play with their meta…  fairly easily.  There are a couple of ways to refine the mesh.  You can go with higher resolution when generating it in the first place, or you can use good old fashioned mesh refinement techniques after the fact.  The latter is probably faster, and gives you more options.

And so it goes.

Now what am I missing… Oh yah, those Cubic surfaces.  And let’s not forget realtime collaboration!

 


Native Metaballs

How about Metaballs?  Isosurfaces? Blobs?

Yah, sure, why not?  Since I’m programming in Lua, there are a couple of ways to do things.  Metaballs, or Blobs, are actually fairly easy to produce, up to a point.  You calculate a bunch of points that define the ‘surface’ of the object.  Then you need to perform some fancy calculations to turn all those points into an actual mesh that can be rendered.  There is one such routine, known as “Marching Cubes”, which is patented, which can perform this operation.  There are other (non-patented) routines, which will do a similar task.  If you’re going to do marching cubes, then you need some cubes…

One thing to notice about the code for this rendering is that it uses an iterator.  Notice in the primary loop here: for v in IterateMetaballs…

That’s a standard Lua iterator pattern.  They come in quite handy for such things.  Of course I could wrap this up in some nice native function like: metaball(balls, resolution), and be done with it.  But, anyone can do that, and besides, by making the iterator available in the raw, you can come up with multiple uses of the points that are generated.

Here, I am using the points to display cubes (with transparency).  The “Blue Bell” tinted spheres ‘inside’ the object are the ‘molecules’ of the shape, which create the isosurface.

In this second picture, I’m doing something a bit different.  The last parameter of the iterator ‘{3,3,3}’ determines the ‘Sample Per Unit’ (spu).  If I were a 3D printer, this might be the ‘layer height’.  So, assuming my “Unit” is 1mm, then having a SPU of ‘3’ would mean a resolution of 1/3 == .3mm.  Again, if I’m a printer, this would essentially be a layer height of .3mm.  Alright, so why do I need a mesh in the first place?

What I could do instead is the following.  Let’s assume my printer is a very dumb pick-n-place machine.  I have these tiny little beads that are .3mm in size.  I have this metaball object I want to construct.  I can just give the printer the metaball description, and it can evaluate the iterator, moving from x-y, layer by layer.  Whenever it receives a ‘positive’ at a position, it places a bead.  No mesh involved.  I’ve essentially ‘sliced’ the geometry and rendered directly to the printer.  The only reason I’d need a mesh is if I wanted to interchange with someone else who needs a mesh.  Well, I won’t take on that burden, I’d rather just send them the description of the geometry, and let some other rendering tool figure out how to turn that into a mesh.

Great, problem solved, and no need for Marching Cubes!

Here’s a final picture with a SPU = {5,5,5}.  That’s essentially a 0.20 mm layer height.  It looks “water tight”.  Again, if you have a printer that can consume this description directly, you don’t ever have to generate the .stl file.  Just “Print”.  It’s a technique similar to sending Postscript to a printer for direct rendering.

At any rate, one step closer to reality.


Native Platonics

The Iron Man 2 movie didn’t quite have the same magic appeal that Iron Man I did, but as sequels are concerned, it still had good entertainment value.  There are a couple of scenes in particular that I liked, with respect to doing something in the real world.

The first scene is after Rodey delivers the Iron Man suite to the Air Force.  Then they have Hammer show them a lot of weapons and end up saying “put all of it in there”.  For me, FabuCAD is kind of like that.

Over the past year, I’ve developed everything from Cubic Surfaces to Platonic solids, to quadrics, and quite a few other things in between, as core drawing primitives.  FabuCAD incorporates all those weapons into its core.  So, for those times when you need the standard CSG objects, like cylinder, cube, sphere, yep, they’re all in there.  And then, when you simply can’t remember how to create a torus on your own, it’s right there.  And of course the ever popular platonics, no 3D package would be complete without those.

No teapot as yet though.

The other scene in the movie that I find to be very interesting, is when he’s visualizing, with some sort of holographic display in his workshop.  He’s talking to the computer, using hand gestures, moving around, and things just happen!  That’s a great user interface.

 


The Funky 4

A few posts back, I talked about a tool chain whereby I used Lua coding to create a polyhedron, which was then rendered by OpenScad.  That tool chain works particularly well when I actually want to perform some boolean CSG operations on my objects.  In many cases though, I’m not really doing any CSG, I’m just generating objects directly using math.

The SuperShape object is one that I’ve used before, to demonstrate that tool chain.  On my machine, the process of rendering one of these supershape objects in OpenScad (using F6) was about a minute and a half.  Well, thinking about the millions of triangles per second that a modern graphics card is capable of displaying, I know it’s not about the drawing speed, but rather the computations.

In the case of these supershapes, there’s really no reason in the world to get the CGAL involved in trying to do CSG operations, because I’m not doing any CSG operations.  So, to go further, I just figured I’d render my shapes directly in Lua, and save a trip through OpenScad.  In the picture above, I’ve rendered the SuperShape 4 times, using a high enough polygon count that it would take a significant amount of time.  This render took roughly 4 seconds of wall clock time to render…

Since there’s not CSG involved, I can simply export to .stl, and be done with it, in that same amount of time.  If I want to do any CSG on this object, I can import it into OpenScad as usual and perform operations there.

What this gives me is a tool chain whereby rapidly experimenting with new math derived shapes is painlessly easy, blazingly fast, and I can export to anything I want to do further processing.

This combined with a coloring scheme that allows me to use colors like: Burnt Sienna, Carribean Green, Carnation Pink, and Eggplant, provides a righteous system.

I did check on Thingiverse, and my first uploaded design was on Nov 20th 2010.  So, I guess that is my anniversary date.  I will be making this little tool available for others to play with about that time.


What a CAD

Diamond’s are anyone’s best friend…

The funny thing about dreaming is sometimes dreams do come true.

I saw this diamond thing on Thingiverse.  My thought was, ‘wow, at 13Mb, that’s quite a nice torture test for a viewer, as well as for a printer’.  So, I thought it would make a perfect test case for my .stl file importer.

And there it is.  It takes a bit of time to render initially, but after that, I can rotate it around with no problems.  It does go rather slowly though, but I am drawing it, and meshes in general, in the most basic of ways, without one iota of optimization.  So, things can only get better eh?

Another thing happens when you’ve been programming too long.  You start to think interesting thoughts in a Calvin and Hobbs sort of way.  One of the thoughts that I had was; “Why can’t I specify colors using something like Crayola Crayon colors?”.

Well, there it is…  Now, ideally, a CAD program would have the facilities to support multiple different types of color models and schemes and whatnot.  There’s Pantone of course, and Sharpie, and Crayola, and myriad others.  Of course there’s licensing to be done to get such a thing, but wouldn’t it be cool if you could do it.

And another thing…  That one year anniversary is rapidly approaching.