quag / mcobj

Minecraft to OBJ (and PRT) converter
BSD 2-Clause "Simplified" License
84 stars 13 forks source link

mcobj: Minecraft to OBJ (and PRT) converter

For example renders see http://quag.imgur.com/minecraft__blender.

If you'd like to show me renders, report problems, suggest improvements, would like builds for other platforms or to ask for help, please email me.

The http://reddit.com/r/mcobj sub-reddit been setup for showing off renders, discussing how to achieve nice effects and news about updates. Feel free to contribute and if it is quiet or empty to stir it up with some posts.

As I'd love to see renders, please email me copies of images you create.

Usage

On Windows:

mcobj -cpu 4 -s 20 -o world1.obj %AppData%\.minecraft\saves\World1

On OSX:

mcobj -cpu 4 -s 20 -o world1.obj ~/Library/Application\ Support/minecraft/saves/World1

On Linux:

mcobj -cpu 4 -s 20 -o world1.obj ~/.minecraft/saves/World1

Flags:

-cpu 4How many cores to use while processing. Defaults to 1. Set to the number of cpu's in the machine.
-o a.objName for the obj file to write to. Defaults to a.obj
-hHelp
-prtOutput a PRT file instead of OBJ
-3dsmax=falseOutput an obj file that is incompatible with 3dsMax. Typically is faster, uses less memory and results in a smaller .obj files

Chunk Selection:

-x -8.4 -z 272.8Center the output to chunk x=-1 and z=17. Defaults to chunk 0,0
-cx 10 -cz -23Center the output to chunk x=10 and z=23. Defaults to chunk 0,0. To calculate the chunk coords, divide the values given in Minecraft's F3 screen by 16
-s 20Output a sized square of chunks centered on -cx -cz. -s 20 will output 20x20 area around 0,0
-rx 2 -rx 8Output a sized rectangle of chunks centered on -cx -cz. -rx 2 -rx 8 will output a 2x8 area around 0,0

Limit the output:

-fk 300Limit the face count (in thousands of faces)
-y 63Omit all blocks below this height. Use 63 for sea level
-hbHide the bottom of the world
-gGray; omit materials
-bfDon't combine adjacent faces of the same block within a column
-sidesOutput sides of chunks at the edges of selection. Sides are usually omitted

Change Log

Change Log
2012-04-03 0.14
  • Support the Anvil world format
  • Update blocks to 1.2.4
  • Add variable height support
2011-09-12 0.13.1
  • Fix build to generate .exe on Windows executable's name
  • Disable: Generate .obj files that can be read without any special flags in 3dsmax
2011-09-11 0.13
  • Add blocks for 1.6 and 1.7
  • Center on spawn point by default
  • Usability: Read commandline from settings.txt file beside mcobj.exe
  • Usability: Prompt for command line when someone double clicks on the exe (no more fighting with Windows cmd or OSX Terminal)
  • Usability: Correct for unquoted spaces in paths to worlds
  • Fix bug: EOF error on empty mcr files in beta worlds
  • Fix bug: crash when -o refers to a missing directory
  • Fix bug: "panic: runtime error: slice bounds out of range" on some chunks
  • Switch to goinstall based building (requires a weekly build newer than go-r57)
  • PRT: invert x and z
  • PRT: remove 2x scaling
  • Generate .obj files that can be read without any special flags in 3dsmax
2011-05-15 0.12
  • Add -x and -z flags for centering using Minecraft's F3 coordinates
  • Change to material names instead of numbers
  • Update blocks.json to handle Minecraft 1.5 blocks
  • Fix bug: materials with extra data, e.g., wool colors, were always grey
  • Fix bug: some leaves showed up as grey blocks
  • Fix bug: -s square not centered on -cx -cz (off-by-one)
  • Add arrays of block data to blocks.json -- beds and saplings
  • Reworked build and release scripts
  • Update source to compile with go release.r57.1
2011-04-17 0.11
  • Add -solid flag for putting sides on the area
  • Add -rx 2 -rz 8 for selecting a rectangular area
  • Slight improvement to glass color (less likely to be black)
  • Read block data from blocks.json instead of being hard coded
  • Remove -hs (hide stone) flag. Now add "empty":true to stone in blocks.json
2011-03-17 0.10.2
  • Add beds and redstone repeaters
  • Update colors from WormSlayer
  • Only invert x-axis for PRT (not both x and z)
2011-03-14 0.10.1
  • Bug fix: colors missing from blocks with extra data (except for wool) in OBJ
2011-03-13 0.10
  • Flip both x and z axis for PRT output
  • Write out blocks around transparent blocks. For example, the block under a torch or the blocks around glass
2011-03-06 0.9.2
  • Rename PRT channel from MtlIndex to BlockId
2011-03-06 0.9.1
  • Fix bug (when PRT support was added) that made OBJ files empty
2011-03-05 0.9
  • Fix PRT export bug where all blocks appeared in a 16x16x128 space
2011-03-05 0.8
  • Add alternative output format: PRT (use -prt flag to enable)
2011-03-05 0.7
  • Add support for the beta world format
2011-02-19 0.6
  • Further tweaks to colors
  • Add color wool blocks
2011-02-17 0.5
  • Switch to WormSlayer's block colors
  • Reverting to relative vertex numbers as abs numbers didn't help with the 3dsmax loading
2011-02-17 0.4
  • Use absolute vertex numbers instead of relative (to support 3dsmax)
  • No longer leak file handles and gzip streams
2011-02-14 0.3  

Limitations

Lots!

Only understands cube blocks (no torch meashes, door meshes and so on) No textures. Just solid colors per block Torches and lava don't emit light ... The no-mesh and no-texture limitations are delibarate. They keep the obj file size and face counts down allowing dumps of large parts of the world without blowing out Blender's memory.

Blender

Requires Blender 2.5.

Steps:

  1. Start Blender
  2. Delete the standard cube (right-click and press delete)
  3. Start the obj importer: (hit space, and type, "import obj" and hit return)
  4. Select the generated obj file and wait for it to import
  5. Enable Ambient Occlusion (switch to Blender's 'World' planel and click the 'Ambient Occlusion' checkbox)
  6. Start a render (hit F12)

Example Run

C:\>mcobj -cpu 4 -s 4 -o world1.obj %AppData%\.minecraft\saves\World1
mcobj dev-7-g1591dec (cpu: 4)
   1/5590 (  0,  0) Faces:  889 Size:  0.0MB
   2/5590 (  0, -1) Faces:  880 Size:  0.1MB
   3/5590 ( -1,  0) Faces:  850 Size:  0.1MB
   4/5590 ( -1, -1) Faces:  849 Size:  0.1MB
   5/5590 (  0,  1) Faces: 1042 Size:  0.2MB
   6/5590 ( -1,  1) Faces:  888 Size:  0.2MB
   7/5590 (  1,  0) Faces:  918 Size:  0.3MB
   8/5590 (  1, -1) Faces:  860 Size:  0.3MB
   9/5590 (  1,  1) Faces: 1678 Size:  0.4MB
  10/5590 (  0, -2) Faces:  906 Size:  0.4MB
  11/5590 ( -1, -2) Faces:  850 Size:  0.4MB
  12/5590 (  1, -2) Faces:  836 Size:  0.5MB
  13/5590 ( -2,  0) Faces:  863 Size:  0.5MB
  14/5590 ( -2, -1) Faces:  851 Size:  0.5MB
  15/5590 ( -2,  1) Faces:  909 Size:  0.6MB
  16/5590 ( -2, -2) Faces:  869 Size:  0.6MB