Voxelizer 1.0 is a script written in Python for Maya. It builds an array of animated cubes in the shape of selected target objects. It takes the color of the cubes from the texture and lighting of the object, and respects visibility and transparency. It also allows keyable voxel and gap sizes, by checking the sizes of optional control objects.
Test scene here:
Voxelizer1.0_test.ma (Maya 2010)
Copy this script and paste into a Python tab in Maya, select target meshes and execute (with ctrl-enter in Windows). Optionally, paste the code into the script editor, select all, and drag to the shelf to create a button.
If nothing is selected, if a group called “voxelGeo” exists the meshes inside it will be used as the targets.
If an object named “voxelScaleCtrl” exists, the voxel system will take its scale value from it.
If an object named “cubeScaleCtrl” exists, each cube will take its scale value from it.
The script samples color and alpha values, but only one value per face; for higher resolution color sampling, subdivide your mesh’s faces.
This script will result in one shader per face; if you run the script more than once, optimize your scene with File > Optimize Scene Size to remove unused nodes.
Maya’s color sampling routines may have trouble with multiple shadow-casting lights; this may depend in part on your video card.
“Verbose output” will print performance statistics during execution.
“Show Maya messages” will allow the display of any errors and command results.
“Profiling” will enable the Python profiler and display detailed statistics about function usage at the end of execution.
“Disable undo” if you’re running out of memory during execution. The script will re-enable undo afterward (if it was on in the first place.)
My machine voxelizes the test scene in about 13 minutes, which is still fairly slow. I’d love to get it as fast as Robert Leger’s Cimea 4D Voxels Preset, I’m afraid that’s going to have to be a C++ plugin… watch this space.