Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OBJtoVox

Voxelizes .obj models with textures into colored .vox files

This was built using AI. I have no idea how long this would have taken me if I did it fully myself. This is free and only took a couple days of work. My original goal with this was so I could import 3d models into Teardown. However I'm also working on a Vox to Minecraft Schematic/Litematic converter and plan to eventually release an all in one.

Usage

Setting up the OBJ Currently this tool has only been tested to use Base Color and Alpha on Principled BSDF in Blender to decide color/opacity. Before using this tool, make sure your OBJ has your desired color or image set to the base color for all visible materials and optionally either the alpha map from a PNG or an opacity map plugged into the alpha, though make sure that if using an opacity map it doesn't have an alpha channel with any transparency. A good rule of thumb is that if the model doesn't look correct in Blender using only the base color, it is not going to look correct after being voxelized. In the image below the model still looks good even after disconnecting the specular texture, so this should be good to go.

Example:

image

Also make sure that rotation and scale are correct and have been applied with CTRL + A.

image

If any changes have been made, export the OBJ to your desired folder. I reccomend using Path Mode: Copy.

image

Drop OBJtoVoxX.X.exe into the model folder, and search CMD in file explorer's search bar and press enter

image

In the CMD window, run OBJtoVoxX.X.exe modelname.obj

image

This should create a file named "modelname_0_12.vox". Open this in MagicaVoxel to confirm it looks correct. If the model is missing textures, this could be because the texture is no longer where the MTL file expects it to be. If texture files use special characters like chinese characters, may not work either.

image

There should now also be a config.txt present in the folder. Click it to open the config

image

You can then edit the values

image

Edit and save the config file, then run the command again to voxelize with the different settings. Explanations for each variable are in the config file, but will give examples of what they do here:

scale: Attempts to multiply the size of the model by this value

scale=10.0:

image

chunksize: Default 128. Anything greater than 256 will cause integer overflow and corrupt the .vox. Smaller chunks use less RAM during conversion but may take more time and hard drive space

chunksize=10: image

chunksize=300: image

maxDim: Maximum dimension size, automatically lowers scale if scale is too big. MagicaVoxel squishes/poorly handles .vox files with dimensions greater than 2000x2000x2000 voxels, but other software (Like Teardown) can handle large dimensions well.

maxDim=3000 (scale=50): image

image

onFloor: When true, the .vox model will be offset so that the lowest part is at Z = 0. Keep in mind this will cut MagicaVoxel max height in half, but can make using/viewing the model easier

onFloor=false: image

colorRanges: Determines which indexes should be used for colors. Most use cases should just leave at 1-255, but Teardown determines materials based on color index and only uses 1-184. Check Teardown modding wiki for palette details.

colorRanges=1-10,20-30: image

voxelsPerUnit: Represents how many voxels is equal to 1 OBJ unit in length (1 OBJ unit = 1 meter in Blender). Is multiplied by scale to determine the final size. A value of 12 is roughly 1m in Teardown, 1 is 1m in minecraft (personally think 0.914 might scale better for MC)

voxelsPerUnit=0.914 (scale=10.0): image

isSolidFill: Experimental and very slow for large dimensions, be patient. If false, only creates the surface/shell and leaves the inside empty. If true, fills in most empty voxels that are behind faces and not directly exposed. Best to test this on smaller scales first. If what are supposed to be outer surfaces get covered in a cloud of voxels, you have flipped normals/exposed backfaces. If the inside has a lot of holes, you may have a leak or some intersecting faces causing it.

isSolidFill=false: image

isSolidFill=true: image

About

Voxelizes .obj models with textures into colored .vox files

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages