Minecraft .obj exporter
Haskell Shell

README.md

mc2obj v0.6.5

mc2obj is a tool to convert part of a Minecraft world to a .obj file, which can be imported into a 3D package such as 3ds max or Blender to make a rendering of that world.

mc2obj is similar to mcobj (https://github.com/quag/mcobj), with the following differences:

  • It automatically generates texture coordinates and applies textures
  • It generates the full geometry, not just blocks
  • Support for custom texture packs

Below is an example rendering of a world exported with mc2obj.

example export

User manual

Extract the archive you downloaded somewhere. Open a command line and go to the mc2obj folder. Type the following (replacing myworld with the name of your save file and the output folder with whatever you want):

mc2obj "%appdata%\.minecraft\saves\world" -o "e:\output" --spawncircle=3 --miny=63

This will output a circle with radius 3, i.e. 7 chunks wide (2 * radius + 1) centered around the spawn point. The --miny=63 argument means it will only export everything at or above sealevel (minecraft worlds go from 0 to 127, with 0 being bedrock and 63 being sealevel). Let's look at some of the other options by exporting part of the Nether:

mc2obj "%appdata%\.minecraft\saves\world" -o "e:\output" --rect=-3,-3,3,3 -n -s -b

This will export the rectangle from (-3,-3) to (3,3) of the nether (-n) with sides (-s) and top and bottom (-b) enabled.

Similarly, you can use --circle and --spawnrect (use mc2obj -? for more information). You can also just export the entire world with -e. Note that depending on the size of your world this may take a long time and result in a very large .obj file. I would recommend using --miny to keep the filesize down:

mc2obj "%appdata%\.minecraft\saves\world" -o "e:\output" -e --miny=63

After exporting, start 3ds max or whatever other 3D package you have and import the .obj file in the output folder. For 3ds max, use the following settings:

3ds max import settings

FAQ

I'm running Linux and your program doesn't work
I have only tested the release on Ubuntu 10.04 and Ubuntu 11.10, but hopefully it should run on other distributions as well (I'm new at compiling for Linux). Make sure you're using the correct version (x86 for 32-bit machines, x64 for 64-bit machines). If it doesn't work, please let me know.

Is there an OS X version?
Not yet. I'm still trying to get OS X working in a virtual machine so I can create a binary. In the meantime, you can compile the source yourself. See the 'How to compile' section below.

How do I run this program/what do I do with these .hs files?
If you just want to run the program, make sure you're getting the binary release (click the big Downloads button in the top right of the Github page) instead of the source code.

I've found a bug
Please check the Known Bugs section below to see if it's in there. If not, please let me know so I can fix it. Just add a new issue on https://github.com/FalconNL/mc2obj/issues (assuming the issue hasn't been reported before).

Why is the exporter so slow?
Unfortunately, generating the correct geometry takes more time than just generating cubes like mcobj does. To speed up exporting, you can increase the minY argument to something like 63 so all the underground caves are skipped. Since mc2obj is still in alpha there are probably still some ways to speed up the program. If you have any suggestions, please let me know. See the FAQ section for more details.

I get the message that the chunks are not generated yet
mc2obj can only generate chunks that have been generated by Minecraft. Especially when exporting an area near the edges of your explored terrain or when exporting the entire world you will frequently get this messsage. If none of the chunks you're trying to export are generated, you're probably looking in the wrong location. See the next question for information on determining the correct chunk coordinates, or use the --spawncircle or --spawnrect options.

How do I determine which chunk coordinates I should use?
While in game, press F3. This will show you a lot of information, among which your x and z coordinates (in the middle of the screen). Divide both of these by 16 to get the x and z coordinates for the chunk you're on.

I imported the model in Blender but I don't see anything
Try zooming out, especially if you used the --miny setting. By default the viewpoint in Blender is too zoomed in to be able to see the world.

I'm using Blender/Cinema 4D/some other 3D package. How do I import the .obj file?
I only use 3ds max, so I'm not familiar with the other packages. The important setting is to use the z-axis as the up direction. Aside from that, use the normals, texture coordinates, etc. from the file rather than recalculating them. If you have other issues, please seek a forum or other help service specific to that package.

Why are all the textures so blurry in the rendering?
Unlike Minecraft, 3ds max (and probably other 3D packages as well) apply texture filtering by default. This is particularly noticeable when doing closeup renderings. You can usually turn this off in your renderer. Note that this will cause moire patterns on overview shots. For 3ds max, the setting can be found at:

  • Scanline renderer: Renderer -> Antialiasing -> Filter maps
  • V-ray: V-Ray -> Global switches -> Materials -> Filter maps

What are these purple blocks?
They're the 1.8 blocks I haven't implemented yet: iron bars, glass panes and fence gates. These will be implemented in the next update.

What render settings should I use?
Whatever you want. I'd recommend some type of global illumination but given the amount of packages, render engines and possible settings I can't go into more detail. Again, seek the help of someone with more experience with your 3D package/render engine.

How do I use a custom texture pack?
Make sure you have ImageMagick installed. Put the required texture files (terrain.png, fire.png, portal.png and sign.png) in the texsplit folder. Run texsplit.bat (Windows) or texplsit.sh (Linux). The next time you export a world it will use the new texture pack. Alternatively, replace the tex folder in your output directory with the one in the texsplit folder and your 3D package should update the textures immediately.

Known bugs

Major:

  • Not all 1.8 blocks have been implemented yet.
  • Redstone wire does not display correctly.

Minor:

  • Paintings, mine carts, animals and other non-block entities are not exported
  • Signs have no text. I have yet to come up with a good way of doing this.
  • Chests may not always orient correctly.
  • Fence texture coordinates aren't entirely correct
  • Some minor player interaction-related geometry effects like pressed pressure plates and lit up redstone ore are ignored
  • Performance still leaves a lot to be desired. For those interested: according to the profiler the two slowest functions are indexString and addFace in ObjExport.hs. Suggestions for performance improvement are welcome.

How to compile

Install the latest version of the Haskell platform. On the command line, execute the following commands (linux users will need to add sudo to all of these):

cabal update
cabal install binary-strict
cabal install cmdargs
cabal install split
cabal install utility-ht

Go to the mc2obj folder. Execute the following command:

ghc mc2obj.hs --make -outputdir=bin -O2 -Wall -fno-warn-missing-signatures -fno-warn-type-defaults

You should now be able to run the program. If not, please let me know.