A Python/numpy implementation of the Menger Sponge/Cube designed to work with MagicaVoxel.
- Set
object.lut = []
to indicate which voxels in a 3x3x3 cube to delete. (0 ... 26) - Call
output(depth, filename)
to return a numpy array of the traditional Menger sponge as well as write it to filename.vox. - Use
inverseOutput(depth, filename)
to output the model of all deleted cubes in the regular sponge.
# Create an object
menger = MengerMagica()
# Call either output() or inverseOutput()
invop = menger.inverseOutput(3, "output.vox")
- Calling inverseOutput results in an internal call to
output()
- Calculations for a call to
output()
for a certain depth occur once. Changing the depth results in recomputation.
The method of using a look up table for voxel deletion was borrowed from Malcolm Kesson.