Hand-printing a 3d bunny | part 2

preparing the bunny mesh in Maya

Kelly Yu
4 min readApr 14, 2019

The project so far

For best results, read part one first!

A rendered Stanford bunny (using Maya built-in renderer)

We want to slice the bunny horizontally into cross sections that correspond to our existing foam sheets so later on we can cut the foam into the shape of the bunny, layer by layer.

Terms defined

  • Maya: a 3d program in the likes of Blender, 3dsMax, and Cinema4D. Think of it as a 3d sculpting and animation tool that allows users to make digital representations of 3d objects.
Rotating the camera around the bunny in Maya
  • Mesh: a polygonal object comprised of faces, edges, and vertices. For example, a cube mesh would have 6 faces, 12 edges, and 8 vertices (corners).
  • MEL: Maya Embedded Language. This is a scripting language native to Maya that corresponds 1:1 with many tasks.

Strategy

Overall plan

  • import the Stanford bunny.obj mesh (the bunny can be found on Stanford’s website)
  • scale the bunny so that each 1 unit in Maya roughly corresponds to 1 inch in real life for an easy conversion factor, and such that the broadest cross section of the bunny can still fit on the largest pieces of foam I have
  • slice the bunny into 1/8 inch cross sections (my foam sheets are 1/8 inch thick)
  • isolate each cross section visually by layer for easy visibility toggling

Execution

Need for automation

Slicing the mesh repeatedly into cross sections was daunting. After making about 10 cuts by hand on the bunny and needing over 100 more, I was ready to turn to scripting. By hand, for each cut you need to:

  1. select the bunny
  2. select the Multi-Cut Tool
  3. click the bunny
  4. adjust the Multi-Cut Tool to slice the bunny at the right height (1/8 inch intervals)
  5. go into component mode
  6. double click a face on the slice to select the entire slice (aka the face loop)
  7. separate the slice from the bunny
Manually inserting a slice onto the bunny mesh

This might not look so bad, but each cut would take me at least 30 sec. That’s about 1 hour for the mundane and repetitive work of 120 cuts, which is enough to make me want to try scripting it instead.

Bunny slicing

I decided to try out MEL for this automation, and after googling some examples figured out this script to do all the cuts along the entire height of the bunny (essentially, steps 1–4):

The bunny after it’s been sliced by the script

Separating the slices

Now that I had a bunch of slices, I wanted them separated from each other into separate objects. In Maya, different objects can be added to layers, and it’s easy to toggle layer visibility on and off, something I would find useful once cutting foam one layer at a time.

After having a rough time with MEL data structures (and the script running slowly), I decided to do this part in Python. My strategy was to look at the highest and lowest point of each face and use that to determine what slice it belonged to.

I was in the middle of converting my psuedo-code into real code, then I realized that the polySeparate command does exactly what I wanted when applied to the whole object itself. Oops.

// does what I wanted this large script to do
polySeparate -constructionHistory 1 bunnyMesh;

Filling out the slices

The bunny started off as a hollow shell, and the slices themselves ended up being these hollow rings. Since the thickness of the shell walls are virtually zero, when viewed from above the actual slice is hard to see. Thus, I wanted to fill in the gaps caused by my earlier slicing with faces.

Filling out the slices manually

Thankfully, Maya has a polyCloseBorder command that takes care of this in a jiffy:

Code used to fill out the slices; funnily enough, if you select all the hollow slices and use the UI to apply the Fill Hole command, the program will do so iteratively, just like it would if you ran this code.

Assigning to layers

With how I separated the slices from the main bunny mesh, sometimes multiple objects would result from a single slice (example — the slice along the ears would lead to two oval disks)

Two disks along the same slice of the bunny, as separate objects

In the case of multiple objects per slice, I prefer to have them combined into a single object, leading to the code here:

If you’re using my code as a guide for your own project, also note that I selected all these objects and removed the history nodes (empty transform nodes) which were causing some of the commands to error. I also placed any newly created objects from the unite operation under the same parent for organization.

Code that assigned each slice to its own layer:

Slicing results

I finally dipped my toes into Maya scripting! It’s been something I was curious about, but without feeling much cause to pursue, so I’m glad this project forced my hand, in a way. All in all, I’d say it went pretty smoothly.

Here’s a fun slinky-like animation I coded up with the rabbit slices:

Real-time animation of the bunny slices forming a bunny
Code used to generate animation, given an existing animation of translating all bunny slices downwards together. This code was applied several times until I was happy with the amount of time between each slice falling into place.

Thanks for joining me on this adventure! Until part 3

--

--

Kelly Yu

Fresh college grad working in tech in the best city, NYC. Likes drawing, dancing, and improv. Writes thought processes of projects and sometimes advice.