Thursday, April 14, 2011

Thursday Afternoon Diversion: A POV-ray Dummy

I recently found myself in need of a basic human dummy for a project that I've got going on over at Analytic Martial Arts. My requirements were/are pretty minimal:

  • Create a stick-figure mock-up of the human body.
  • Pose the body as needed.
  • Efficiently create top, front, side, and three-quarters snapshots of the model.
  • Composite the four snapshots together in a 2x2 grid.

I initially thought to use Blender, since it's designed specifically for creating models and such, but ran into a couple of issues which complicated matters. I'm more interested in body geometry than aesthetics and, as a consequence, often know specifically where I want particular points to be positioned in 3-space. Blender, being a mesh-based modeler, doesn't provide me with a convenient way (that I'm aware of) to say "I want a cylinder of radius blah, with ends positioned here and here". Additionally, I couldn't figure out a way to render multiple camera-angles from the command line. Given that Blender has an embedded Python interpreter it's undoubtedly possible, but the answer wasn't obvious.

Since Blender wasn't going to cut it I decided to fall back to POV-ray. Moray seems to be the preferred modeler for POV-ray these days, and was an improvement over Blender, but didn't quite cut it either. The modeling process in Moray involves creating unit objects (a 1x1x1 cube, a sphere of radius 1, etc.) centered at the origin and then applying standard transforms to them. Provided that I wanted to do some non-trivial math I could come up with the appropriate transforms to get the objects positioned the way I wanted, but that would basically defeat the purpose of using a modeler in the first place.

What I really needed was an interface which would let me place primitive objects directly ("I want a sphere of radius blah w/ center x,y,z") and then view/modify them via the GUI. One of the many front-ends available for POV-ray may very well do that, but as I've yet to identify one I ended up going back to basics and using a text editor to build my POV-ray files by hand.

POV-ray doesn't have built-in support for modeling (armatures, skins, etc.) like Blender does, but it turned out to be straightforward to build a dummy that would suit my needs. Limbs are cylinders with vitruvian proportions, joints are spheres, and the location of each joint in 3-space is represented via a named vector. Defining hand- and foot-looking objects in terms of these vectors was a little bit of a challenge; I ended up creating them as cylinders with one end at <0,0,0> and then using the Point_At_Trans macro to orient them properly. Using multiple camera definitions in conjunction with m4 allows me to batch render different views which can then be stitched together using montage.

The result ain't pretty, but its good enough for MA demonstrations:

The POV source file is here; making it do anything other than stand is left as an exercise for the reader.

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home

Blog Information Profile for gg00