2020-06-29 11:43:01 -07:00
# General
2020-09-16 10:30:55 -07:00
Convert voxel volume formats between each other or export to obj or ply.
2020-06-29 11:43:01 -07:00
2021-12-16 08:07:28 -08:00
* [Supported voxel formats ](../Formats.md )
* [Scripting support ](../LUAScript.md )
2020-11-30 15:11:20 -08:00
2020-06-29 12:37:14 -07:00
## Usage
2021-12-21 08:07:34 -08:00
`./vengi-voxconvert --merge --scale --input infile --output outfile`
2020-06-29 12:37:14 -07:00
2021-12-16 10:40:17 -08:00
* `--export-palette` : will save the included palette as png next to the source file. Use in combination with `--src-palette` .
2021-12-21 08:07:34 -08:00
* `--filter <filter>` : will filter out layers not mentioned in the expression. E.g. `1-2,4` will handle layer 1, 2 and 4. It is the same as `1,2,4` . The first layer is `0` .
2021-12-16 10:40:17 -08:00
* `--force` : overwrite existing files
2021-12-21 08:07:34 -08:00
* `--input <file>` : allows to specify input files. You can specify more than one file
2020-06-29 12:37:14 -07:00
* `--merge` : will merge a multi layer volume (like vox, qb or qbt) into a single volume of the target file
2021-12-21 08:07:34 -08:00
* `--mirror <x|y|z>` : allows you to mirror the volumes at x, y and z axis
* `--output <file>` : allows you to specify the output filename
* `--rotate <x|y|z>` : allows you to rotate the volumes by 90 degree at x, y and z axis
2020-06-29 12:37:14 -07:00
* `--scale` : perform lod conversion of the input volume (50% scale per call)
2021-12-21 08:07:34 -08:00
* `--script "<script> <args>"` : execute the given script - see [scripting support ](../LUAScript.md ) for more details
2021-11-30 14:06:27 -08:00
* `--src-palette` : will use the included palette and doesn't perform any quantization to the default palette
2021-12-21 08:50:19 -08:00
* `--translate <x:y:z>` : translates the volumes by x (right), y (up), z (back)
2020-06-29 12:37:14 -07:00
Just type `vengi-voxconvert` to get a full list of commands and options.
Using a different target palette is also possible by setting the `palette` config var.
2021-12-21 08:07:34 -08:00
`./vengi-voxconvert -set palette /path/to/palette.png --input infile outfile`
2020-06-29 12:37:14 -07:00
The palette file has to be in the dimensions 1x256. It is also possible to just provide the basename of the palette.
This is e.g. `nippon` . The tool will then try to look up the file `palette-nippon.png` in the file search paths.
2020-08-02 10:51:32 -07:00
You can convert to a different palette with this command. The closest possible color will be chosen for each
color from the source file palette to the specified palette.
2020-09-16 10:39:36 -07:00
2021-12-21 10:47:48 -08:00
### The order of execution is:
* filter
* merge
* scale
* mirror
* rotate
* translate
* script
2021-12-16 08:07:28 -08:00
## Level of detail (LOD)
2020-11-13 10:40:39 -08:00
Generate a lod scaled by 50% from the input model.
2021-12-21 08:07:34 -08:00
`./vengi-voxconvert -s --input infile.vox output.vox`
## Merge several models
Merge several models into one
`./vengi-voxconvert --input one.vox --input two.vox --output onetwo.vox`
2020-11-13 10:40:39 -08:00
2021-12-16 08:07:28 -08:00
## Generate from heightmap
2021-12-15 12:08:09 -08:00
Just specify the heightmap as input file like this:
2021-12-21 08:07:34 -08:00
`./vengi-voxconvert --input heightmap.png --output outfile.vox`
2021-12-15 12:08:09 -08:00
2021-12-21 10:38:42 -08:00
## Translate the voxels
You can translate the voxels in the world like this:
`./vengi-voxconvert --translate 0:10:0 --input heightmap.png --output outfile.vox`
This would move the voxels 10 units upwards. But keep in mind that not every format supports
to store a translation offset.
2021-12-16 08:07:28 -08:00
## Execute lua script
Use the `--script` parameter:
2021-12-21 08:07:34 -08:00
`./vengi-voxconvert --script "cover 2" --input infile.vox --output outfile.vox`
2021-12-16 08:07:28 -08:00
This is executing the script in `./scripts/cover.lua` with a parameter of `2` .
2021-12-21 08:07:34 -08:00
`./vengi-voxconvert --script "./scripts/cover.lua 2" --input infile.vox --output outfile.vox`
2021-12-16 08:07:28 -08:00
This is doing exactly the same as above - just with a full path.
See the [scripting ](../LUAScript.md ) documentation for further details.
## Extract palette png
2021-11-30 22:44:25 -08:00
Saves the png in the same dir as the vox file
2021-12-21 08:07:34 -08:00
`./vengi-voxconvert --src-palette --export-palette --input infile.vox --output outfile.vox`
2021-11-30 22:44:25 -08:00
There will be an `infile.png` now.
2021-12-17 06:46:55 -08:00
## Extract single layers
Extract just a few layers from the input file.
2021-12-21 08:07:34 -08:00
`./vengi-voxconvert --filter 1-2,4 --input infile.vox --output outfile.vox`
2021-12-17 06:46:55 -08:00
This will export layers 1, 2 and 4.
2021-12-16 08:07:28 -08:00
## Convert to mesh
2020-09-16 10:39:36 -07:00
You can export your volume model into a obj or ply.
2021-12-21 08:07:34 -08:00
`./vengi-voxconvert --input infile.vox --output outfile.obj`
2020-09-16 10:39:36 -07:00
2021-11-30 22:44:25 -08:00
Config vars to control the meshing:
2020-09-16 10:39:36 -07:00
2020-09-30 13:26:51 -07:00
* `voxformat_ambientocclusion` : Don't export extra quads for ambient occlusion voxels
2020-10-01 14:25:34 -07:00
* `voxformat_mergequads` : Merge similar quads to optimize the mesh
* `voxformat_reusevertices` : Reuse vertices or always create new ones
2020-09-30 13:26:51 -07:00
* `voxformat_scale` : Scale the vertices by the given factor
* `voxformat_quads` : Export to quads
2020-09-30 14:18:24 -07:00
* `voxformat_withcolor` : Export vertex colors
* `voxformat_withtexcoords` : Export texture coordinates
2020-09-16 10:39:36 -07:00
2021-11-30 22:44:25 -08:00
See `./vengi-voxconvert --help` or [configuration ](../Configuration.md ) for more details.
2020-10-01 14:23:46 -07:00
## Batch convert
To convert a complete directory of e.g. `*.vox` to `*.obj` files, you can use e.g. the bash like this:
```bash
2021-12-21 08:07:34 -08:00
for i in *.vox; do vengi-voxconvert --input $i --output ${i%.vox}.obj; done
2020-10-01 14:23:46 -07:00
```
2021-12-16 08:07:28 -08:00
2021-12-17 10:11:57 -08:00
An example for the windows powershell to extract single layers into a new model
```ps
$array = "1-2,5", "1-2,7"
foreach ($i in $array){
2021-12-21 08:07:34 -08:00
./vengi-voxconvert --filter $i --input input.vox --output output_$i.vxm
2021-12-17 10:11:57 -08:00
}
```
2021-12-16 08:07:28 -08:00
## Screenshots
![image ](https://raw.githubusercontent.com/wiki/mgerhardy/engine/images/voxconvert-export-to-obj.png )
![image ](https://raw.githubusercontent.com/wiki/mgerhardy/engine/images/voxconvert-export-obj.png )