Revamping VoxyGen

After a few busy months of other projects, I’m ready to knock the dust off of VoxyGen!

If you’re not familiar, voxels are essentially the 3d form of pixels. You can use these little blocks to make some staggeringly beautiful scenes, robust interior designs, fun data visualizations, and of course, giant robots. My pal megavoxels on Instagram does an excellent job curating voxel art if you want to see some great examples.

Voxygen is substantial extension for the py-vox-io package, allowing users to turn mathematical expressions and geometry commands into Magicavoxel .vox files. The goal of VoxyGen is to implement a domain-specific language with which users can easily create generative voxel art. Ultimately, I’d like to interface this with a browser client or Discord bot or something to allow super easy access.

Since it’s been about six months since I opened the project, of course I had to do some fiddling with dependencies. When importing py-vox-io, you use an internal package called pyvox like so:

import numpy as np
from pyvox.models import Vox
from pyvox.writer import VoxWriter

PyCharm attempts to fill this dependency with pip install pyvox, which unfortunately does not work, as it gets confused with an old medical imaging package (actually called pyvox) from 2006. You’ll receive the error:

ERROR: Could not find a version that satisfies the requirement pyvox (from versions: none)

To rectify this, one can simply pop open the PyCharm console and type pip install py-vox-io

Sweet.

It’s alive! Something you may notice is the obfuscation of x, y, and z dimensions from the user. This is because, for some odd reason, py-vox-io regards the second dimension as vertical. I’ve seen this in a few other places before, namely older style modeling tools like Blockbench. Personally, I find it absolutely egregious and I’m willing to take great pains to right this wrong.

Let’s do something a little more exciting. I revamped a fun little function called generate_spires:

The code behind the scenes is still a bit of a mess, but the results are pretty neat. Here’s a few more generative pieces from the spire function.

Neato. Next time, I’ll refactor the spires function for efficiency and maybe add some new toys to the mix. If you want to follow the project, it’s on GitLab. Happy coding!

Leave a comment