Mon Apr 4 00:36:50 PDT 2011

blendcraft I

EDIT: Turns out it's been done before.


There's a project I've been half-thinking about for, oh, three months now. Since I've made precisely zero progress on it, I'm posting about it on my blog in the hope of forcing future me into being less lazy.

Not that I'm talking about implementing the weather simulation idea. What the thing is, I'm not happy with the draw distance in Minecraft. It's an infinite world, yet you only see about a square kilometer of it at a time. You'd expect poking around Minecraft would be something like hanging out on the Ringworld, but it's more like a PC port of Turok The Dinosaur, with, amazingly, even worse graphics. There are mods that increase it, but for a couple of good reasons, and several bad ones, Minecraft doesn't run at the thousands of FPS you'd expect from the great big pixels, and, of course, the number of polygons the game has to render as the draw distance increases, increases as O(n^2). So what we're looking for here is some kind of offline renderer, like, hey, Blender, why not.

Recent diversions aside, I am not actually a programmer, so I'd like to get this done with a minimum of pain. Ideally, this would be by using software that someone's already written, but no dice.

So what I need to do is figure out how to parse a Minecraft save file, and then programmatically tell blender where to place a couple thousand cube objects. I will call this Feature 1, since I expect it to be hard. Feature 2 will be fetching block types, and texturing the imported cubes. This will be the 1.0 release, since you could take a Minecraft screenshot of the world at day, and place it next to a Blender render, and they should look the same, except the render won't have the cloud layer, but it will have directional shadows cast from the sun. Feature 3 will be importing lights, for interior shots. Feature 4 will be a in-game button that you can push, which will take the time of day, player location, and which way they're looking, set the sun angle and camera position accordingly, render an image in the background, then pop it up in its own window. Feature 5 will cure cancer, make all the shareholders rich, and guarantee me a Nobel Prize. (Implementation details forthcoming.)

Now, how to do this? Blender has a Python API, that's sorted, and hey, there just so happens to be a Python library for manipulating Minecraft save files! Whadda snap!

Getting it working is annoying, (PyMclevel wants NumPy, and, this is critical, 64-bit NumPy requires a 64-bit version of Python, or else it spews amazingly unhelpful error messages[1] at you.) but eventually my Python install, Blender, PyMclevel, and NumPy all cooperate. Now it's just a matter of moving data from one program to another.

How hard could it be?


1:

>>> import mclevel

    Traceback (most recent call last):
      File "", line 1, in 
        import mclevel
      File "C:\Users\bbot\Downloads\pymclevel-20100920\mclevel.py", line 112, in 
        import nbt
      File "C:\Users\bbot\Downloads\pymclevel-20100920\nbt.py", line 23, in 
        from numpy import array, zeros, uint8, fromstring
      File "C:\Python27\lib\site-packages\numpy\__init__.py", line 136, in 
        import add_newdocs
      File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 9, in 
        from numpy.lib import add_newdoc
      File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in 
        from type_check import *
      File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in 
        import numpy.core.numeric as _nx
      File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 5, in 
        import multiarray
    ImportError: DLL load failed: The specified module could not be found.
>>> 


Posted by | Permanent link | File under: important, nerdery