Multiple programs for Minecraft save file data extraction and 3D model generation based on save files. Also several well documented custom C libraries with minimal prerequisites for wavefront 3d model handling and Minecraft save file handling.
- Generate a 3d model based on your Minecraft savefile blazing fast
- extract chunk nbt from region files
- generate mtl from minecraft resource packs
- generate obj files from minecraft resource packs
In order to get started either download the parts of the precompiled release that apply to your system or compile the source code yourself. In order to compile use make, which is configured to allow for separate compilation of each utility, or complete compilation using the 'all' target ('windows' for cross-compilation).
Multiple utilities for Minecraft region file parsing. Either extract all chunk NBTs in a region file or just a single one.
This program extracts all the chunks in the given region file into nbt files that will be created in the provided directory.
regionFileReader <path to region file> <output directory>
This program extracts only a single chunk with the given chunk coordinates into an nbt file.
chunkExtractor <path to region directory> <x> <z>
Multiple tools that can take in Minecraft related files as input and create 3D representations of your worlds
An open customizable chunk to 3d model converter. Takes in a chunk nbt file, a material file defining the look of blocks, an object file for non cube blocks and creates a 3d model based on that. Ideally the nbt file will be extracted using one of the tools above.
modelGenerator <path to nbt file> ...
The program accepts the following additional arguments:
- -l $y+ $y- :limits the result model to the given vertical range
- -f :disables face culling
- -h :displays help
- -s $s :changes the block side in the result side to the given s argument
- -m $filename :sets the given filename as the source mtl file
- -o $filename :sets the given filename as the source special objects file
- -out $filename :sets the given filename as the output filename
The generator if provided with the -m flag followed by the mtl file filepath will use the provided file as a material source and generate the obj file to support mtl materials. Blocks of minecraft:dirt will use a mtl material called dirt and so on. Feel free to create your own mtl file or use the mtl Gen to create one quickly.
So in order to handle non cube blocks the generator needs an obj file defining models for those "special" blocks. If that file isn't provided the generator will simply assume everything is a cube. In order for the special obj file to get interpreted properly the vertex coordinates in each object must be relative to the center of the object.
A version of modelGenerator using multiprocessing that can generate models same as modelGenerator, but with multiple chunks at the same time. This is the program you are going to want to use to generate your model. You provide coordinates of a chunk that will act as a center for your model, a radius in which surrounding chunks will be added to the model and the radiusGenerator will create a large model for you. The argument interface is very similar to modelGenerator and all rules about assets and limitations from modelGenerator apply here. That being said here is how you use radiusGenerator:
radiusGenerator <path to region directory> <x> <z> <radius> ...
You may want to compile the Linux version of radiusGenerator and use it under Windows for speed. You may accomplish that by installing Cygwin and compiling radiusGenerator in their environment. However due to POSIX shared memory management differing too greatly from Windows the cygserver needs to be running. In order to do that install the correct package, then run:
cygserver-config
net start cygserver
Minecraft stores it's assets in it's own unique way. Due to this, and a need to provide assets for 3D model generators scripts were created. Naturally those assets aren't provided here since I want these programs to be Minecraft version independent (and I don't want to be sued).
A script for generating complete and valid mtl files for modelGenerator
mtlGen.py <path to /assets/minecraft/textures/block directory of a resource pack> ...
The script accepts the following additional arguments:
- -s :Generates a simplified mtl file that doesn't use textures, but solid colors generated by averaging out RGBA values of all pixels
- -t :Causes all textures with _top in name to be generated without it
- -c :Enables green color correction to correct for the fact most vegetation textures are stored in greyscale
Distribute the result at your own risk.
A script for generating a complete obj file containing special object definition for modelGenerator
objGen.py <path to /assets/minecraft directory of a resource pack>
Distribute the result at your own risk.
Batch script combining objGen.py and mtlGen.py in case you don't want to figure out how to use the two scripts
./quickGen.sh <path to /assets/minecraft directory of a resource pack>
You may generate mtl and obj files based on resource packs, or Minecraft default assets. In order to find them, extract your minecraft version jar file as if it is a file archive. Inside you will find default Minecraft textures and models.
For parsing of the nbt files I have chosen to use the cNBT library. These are compiled automatically using make, and then linked together into cNBT.o.
Most of the code has been organized into four "libraries". These may prove to be useful should you want to parse Minecraft save files or generate wavefront 3D models. Feel free to use these as libraries in your projects just make sure to read the license before you do so. The documentation for functions in these libraries should be mainly in header files and on GitHub Pages, and I will gladly expand it should there be a need so just let me know.
- regionParser
This library provides three functions for parsing region files. You can either extract an entire chunk from the given region file, or extract all of them at once. - chunkParser
This library utilizes the cNBT library to extract information about blocks from Minecraft NBTs - model
This library is capable of generating wavefront 3D models - generator
This library utilizes chunkParser and model to provide a simple interface with which you can quickly generate a 3D model from a Minecraft save file
This work is licensed under the MIT license.