Skip to main content

VoxelWorld

Create delicious Voxel worlds in Python

Live demo on Py.Cafe ☕

image image

Install

From PyPi

pip3 install voxel_world

From source

git clone https://github.com/jackparmer/VoxelWorld.git
cd VoxelWorld
python3 -m pip install .

from voxel_world import VoxelWorld

About

For physics simulation, games, art, and fun

Inspo: https://github.com/wwwtyro/vixel

Features!

  • Automatic GIF generation
  • Numpy 3d ones array in -> Voxel world out
  • Fast-ish (as fast as rendering on the CPU can be)
  • Portable! Outputs simple image files
  • Notebooks! Works well in the Jupyter notebook ecosystem
  • Eye candy! Ambient occlusion, specularity, etc

Known issues (TODO)

  • Speed: Need to migrate to a GPU-based renderer while maintaining portability (suggestions?)
  • Illumination: Light source ray tracing is wonky - but you can fake it (see light_source.py example)
  • Cut offs: The bottom of some voxel cubes are cut off - I'm not sure why
  • Likely much more...

Examples

Animations

from voxel_world import Volume, Surface, Agent, Sequence

volume = Volume(Volume.purlin_matrix(64));
surf = Surface(volume);
agents = [Agent(surf, mask) for mask in Sequence.snake(grid_size=64, num_steps=1000)];
seq = Sequence(agents);

seq2 = seq.apply_bg(volume)

seq2.save('voxel_animation64_v2.gif')
image

Surfaces API

from voxel_world import Volume, Surface;
volume = Volume(Volume.purlin_matrix(32)); surf = Surface(volume)
surf.color = (255,0,0)
volume.add(surf).show()

image

Randomly generated worlds

Live demo on Py.Cafe ☕

import random; import vnoise
from IPython.display import display, Image as IPImage
from voxel_world import Volume

noise = vnoise.Noise()

# Display in Juypter
display(IPImage(Volume(
    np.array([[[1 if noise.noise3(x / 10.0, y / 10.0, z / 10.0) > random.uniform(-0.2, 0.2) else 0 for z in range(16)] for y in range(16)] for x in range(16)], dtype=np.uint8),
    theme=random.choice(list(Volume.themes.keys())),
    resolution=10,
    viewing_angle=(random.randint(0, 90), random.randint(0, 90)),
    zoom=2.0,
    show_light_source=False,
    dark_bg=False
).byte_stream().getvalue()))

image

image

image

image

examples/color_matrix/sand_world.py

image

examples/lighting/light_source.py

download (1)

examples/color_matrix/jill_of_the_jungle.py

jill_of_the_jungle

examples/color_matrix/earth_tones.py

earth_tones

Mono-color themes

from voxel_world import Volume

world = Volume.show_themes() # Jupyter notebook only

image

Metadata

Release files for voxel-world 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for voxel-world 0.2.1
File Size Uploaded
voxel_world-0.2.1.tar.gz 8.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for voxel-world 0.2.1
File Interpreter ABI Platform
voxel_world-0.2.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 8.3 MB

Release files / voxel_world-0.2.1.tar.gz

Download URL voxel_world-0.2.1.tar.gz
Size 8.3 MB
Tags Source
SHA-256 checksum
How to use checksums
4f9e04ee75e25dea289ca8eee730a40fb7ddd1aa684368f9b39852a4c0d9f902
BLAKE2b-256 checksum
How to use checksums
c13dc54ebf49293b8d213b567d552170a11345a5d85dcc33278d12348064bb6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.6

Release files / voxel_world-0.2.1-py2.py3-none-any.whl

Download URL voxel_world-0.2.1-py2.py3-none-any.whl
Size 9.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
bc7d6396da0ff71d46327ca90742d64cf4386410da762d537d6f375b56166a5a
BLAKE2b-256 checksum
How to use checksums
a209668f4ea8ef1273321726eda068c6001596bae1507b80b21d621dd62aaab0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page