Skip to main content

A python io to load/write/visualize vox files (MagicalVoxel's .vox format).

Project description

MidVoxIO

GitHub Workflow Status (with event) PyPI Downloads

The python IO to load/write/visualize magical voxel's .vox format.

Install

pip

pip install midvoxio

through repo

  • clone the repo
  • add the repo to path
  • Install numpy and matplotlib if you haven't

Usage

vox_to_arr()

use vox_to_arr() to parse .vox file into numpy array.

from midvoxio.voxio import vox_to_arr

print(vox_to_arr('vox/99/3x3x3.vox').shape)

result:

(3, 3, 3, 4) # the four axis are (x,y,z,color), color is [r,g,b,a] here

multiple models

if there are multiple models in one vox file, use vox_to_arr('path',n) to get the nth model's array. use vox_to_arr('path',-1) to get the array of combined model.

viz_vox()

use viz_vox() to visualize your .vox file. It uses matplotlib to plot the file internally.

from midvoxio.voxio import viz_vox

viz_vox('vox/99/3x3x3.vox')

then, the python will give you a 3d plot.

get other info

use get_rendering_attributes(),get_cameras(), and get_materials() to get vox info.

>>> from midvoxio.voxio import *
>>> print(get_cameras('vox/99/cars.vox')[0])
{'id': (0,), 'attributes': {'_mode': 'pers', '_focus': '0 0 0', '_angle': '0 0 0', '_radius': '0', '_frustum': '0.414214', '_fov': '45'}}
>>> print(get_rendering_attributes('vox/99/3x3x3.vox')[0])
{'_type': '_inf', '_i': '0.6', '_k': '255 255 255', '_angle': '50 50', '_area': '0.07'}
>>> print(get_materials('vox/99/3x3x3.vox')[0])
{'id': (0,), 'properties': {'_type': '_diffuse', '_weight': '1', '_rough': '0.1', '_spec': '0.5', '_ior': '0.3'}}

write_list_to_vox()

use write_list_to_vox to generate vox file from exist python list. You can use this function to export the python list as vox file, so you will be able to edit vox file in python.

from midvoxio.voxio import write_list_to_vox,plot_3d

arr=[] # define your python list that represent the 3d model here

# define your palette that relate to your model here
# palette will be able to be automatically generated in the future
palette=[]


# you can use plotio to viz your arr before you save it to vox
plot_3d(arr) # visualize your arr

write_list_to_vox(arr,'fname.vox',palette_arr=palette) # then, you save the 'fname.vox'

# you can also use png palette
palette_path='palette.png'
write_list_tov_vox(arr,'fname.vox',palette_path) # then, you save the 'fname.vox'

Others

  • This project was originally created for me to use it myself, so the API design is casual and the error message is not complete. Will consider make it more formal if there are really people using it.
  • Gromgull's py-vox-io is good to use, but only for MagicalVoxel 0.98 or older version, and he somehow stop updating. This voxio reuse some of Gromgull's code (mostly in parser), but now it fit MagicalVoxel 0.99. Also, there are also new features like viz_vox() to visualize the vox array without using magicalvoxel.
  • Lots of functions are still under development.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

midvoxio-0.1.4.tar.gz (79.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

midvoxio-0.1.4-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file midvoxio-0.1.4.tar.gz.

File metadata

  • Download URL: midvoxio-0.1.4.tar.gz
  • Upload date:
  • Size: 79.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for midvoxio-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8f2557d173f3cda93d3a299cc6938108b5d343c87020a5fdfeb8d621d67b6aaa
MD5 52d31ef66b5ed593a71657501ff32b71
BLAKE2b-256 3adfc5a5d8160815d008a6991fa8a79501f30a1990680ac0a9b1156838b75ef8

See more details on using hashes here.

File details

Details for the file midvoxio-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: midvoxio-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for midvoxio-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 097b79f6590c169ef1b9294fe8f4027b0b100f197a1f0f705d047a3796f379f5
MD5 280b0b9eca8bec3777513f0140a9c039
BLAKE2b-256 9a01a6298a24496a1a14ba6e130e9bc2879fe144976aa988f7408e9e129f2296

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page