Posts Tagged ‘Blender’

Four Plans and a Ziggurat

June 28th, 2010

After we figured out how to greatly simplify our 3d models, Sara and I turned out attention to creating different levels of elevation. As a concept this is pretty simple; we used different brightnesses in areas of our 2d picture to tell Blender which shapes we wanted to be the highest, second highest, etcetera., all based on assigning thresholds of pixel value to different “z axis” numbers, which in Blender would become the elevation of the sprinkles.

Thrilled with our success for all of half a day or so, we quickly came to the realization that because we were using sprinkles (which are square), even with a wide range of elevation options, making a smooth hemisphere with the Cupcake would be almost impossible. It’d be like trying to create a pyramid or a dome and getting a ziggurat instead.

Ziggurat!

So we began brainstorming ideas for creating half a sphere over the surface of our model in Blender, using only the Python scripts. This was problematic to say the least because a) most of Blender’s power comes from the manipulatable interface of the model itself, as well as the hotkeys. Both of which are useless when scripting; and b) There is no “create half sphere” handy hotkey period, even if we could use them. In a fit of creative delusion, frustrated hair-pulling and occasional trips to the local icecream shop, we came up with four ideas. (The last one worked, in case you were panicking on our behalf.)

Idea 1 went something like this: “If we create a whole sphere (Blender lets us do this pretty easily) and chop it in half, we’ll have half a sphere!”   Not only did we fail to find a reasonable way of removing half a sphere’s vertices, but we also realized that we’d have to fill in the bottom of what would essentially be an overturned bowl shape. That idea was crossed out. I’m sure it’s possible to do, but our fate lay along a different path etcetera etcetera.

Idea 2: “There’s this cool modifier called ‘Subsurf’! It makes things all rounded!” I’m not quite sure why this one was a flop. I think it had something to do with my tendency to form vague ideas around nifty buttons in art programs.

Idea 3: “We could create branching arcs above the x-y plane, and just fill in the shell with vertices.” See “Idea 2”.

Idea 4 (The One That Worked): “Wait! Boolean expressions! Yes!”

The gist of what we ended up doing is that we realized boolean operations on different objects are pretty simple to script. Boolean options in Blender work just as they do in logic. “And”, “or”, and “not”. We used the Difference boolean operation on a cube and a whole sphere, after positioning them so that they overlap about halfway. What this did was create a sort of ghost mesh of a half-sphere, by telling Blender “remove all of object A that intersects with object B”. (“Difference” is the only Boolean operation in Blender where it matters what order you specify the two objects). So we ended up with a hemisphere (like we wanted), because the rest of that sphere shape overlapped with the dummy cube- which we deleted afterwards.

Some domes

Now that we could create rounded surfaces wherever we wanted; the next step was to let the user specify where they wanted them, using a GUI.

Stickzilla, or: Triangle Meshes Hate Us

June 10th, 2010

After we used Sprinklation to modify pictures into printer-friendly images, our next step was to give these Sprinkles a third dimension. For that we needed Blender, a vastly complex (but free!) 3D modeling program that lets you script in Python. One of the reasons we chose Python for this project in the first place was that so many CAD-type programs utilize it.

To script a 3D object you need to specify the coordinates of its vertices. In the case of a Sprinkle- which is essentially a cube- eight of them. But all we really need for that is the uppermost “origin” coordinate of each Sprinkle, and a Sprinkle’s length. Those three elements are what we exported from our Python program as a text file- and then imported into Blender. Once there we scripted the creation of each Sprinkle we were given, using an arbitrary value for the height of every one. Changing this “z value” is something we’ll come back to later when we start exploring different topographical heights in our images.

This all sounds pretty straight-forward, but right here is about the time we started running into problems- all of which came up as marvelously cryptic error messages when we ran this Blender output through Skeinforge. (Skeinforge is an open-source print-head mapping software that translates 3D models into something the Cupcake can use).

Our first problem had to do with a warped triangle-filled structure that we were getting instead of a clean, solid cube. If you specify four vertices they should make a face, right? I mean, a square face only has four vertices. Turns out if you don’t list the vertices in order (clockwise or counter-clockwise), the entire thing twists itself up and then the computer explodes. (not really).

So for future reference, a “hole in the triangle mesh”, despite the fact that there aren’t supposed to be triangles in your image anywhere ever, means something along the lines of “you fail at playing connect-the-dots.”

Here are some pictures from Blender:

We refer to him fondly as Stickzilla.

Circuit Boards

November 20th, 2009

During the past couple of weeks, Sara and I have been working on learning Blender and building our Cupcake 3D printer, pretty much simultaneously.  Recently we pulled together some of the chips that attach to our motherboard on the Cupcake, including an exciting field trip to find a vice in the Art department, and a thorough overturn of our box-o-parts to root out missing motherboard parts.  Which we didn’t find!  It was exciting.  The good news is that they’re tiny little bits that Professor Jadud probably has, so that isn’t really anything more than a hiccup.

We worked on the motherboard (or, more precisely, itemized the parts we were missing), the extruder control boards (three of them), and their corresponding stepper motors.  We also popped in the parts on the six opto endstops; they’re tiny little boards that still need to be soldered.

As far as Blender goes, we’ve essentially split the learning of it up into two approaches:  Sara’s tackling input scripting in Python and I’m working on going through all the settings and buttons and views and layers and lightings and angles and… well, you get the point.  Together we should be able to beat Blender into the dust.  Figuratively.  With.. you know, code.

Anyway, here are some pictures!  Complete with “Hippy Ribbon”, which is the endearing name in the Makerbot Cupcake’s tutorial for the rainbow wires.  The pictures are of an Extruder control, the Motherboard, and one of the Opto Endstops, respectively.

Extruder control

Motherboard (so far)
Optop Endstop

Working with Blender

November 2nd, 2009

Stephanie and I have started looking at the 3D imaging program Blender. It’s a very large and complex program and we’re still trying to figure out just how to navigate around it.

However, much progress has been made, especially with becoming familiar with the idea of scripting. The tutorial in the Blender 3D: Noob to Pro wikibook (http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro), was a good starting point in learning 1) how to navigate around Blender’s Python API, such as its built-in text editor; 2) the fundamentals of how scripting works and some basic Blender Python commands. This involved using the NMesh Module, which allows one to create a NMesh object and then add vertices and faces to the object.

Creating the NMesh object:

obj = NMesh.GetRaw()

Creating a vertex and adding it to the the NMesh object’s vert list:

v0 = NMesh.Vert(0.0, 0.0, 0.0)

obj.verts.append(v0)

Creating a face, give it some vertices, then add it to the NMesh object’s faces list:

f0 = NMesh.Face()

f0.v.append(obj.verts[3])

f0.v.append(obj.verts[4])

f0.v.append(obj.verts[2])

obj.faces.append(f0)

In this way I was able to create multiple faces, which utilized many vertices, and eventually create a 3D pyramid:

A pyramid created from a Blender Python script

A pyramid created from a Blender Python script

Next, I tried a little more complex figure and created a box sitting on a 2D plane (I like to call it a building):

A more complex 3D object

A more complex 3D object

In the near future, I would like to play around with the other available modules of the Blender Python API (http://www.blender.org/documentation/249PythonDoc/), especially the Mesh Module, which I would like to compare to NMesh and see which one, if either, would be better suited to work with over the course of this project. Also, I would like to look into more efficient object creation techniques, via for loops and such.