Skip to main content

Delicious Voxel worlds in Python

Project description

VoxelWorld

Create delicious Voxel worlds in Python

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

Randomly generated worlds

import random
import numpy as np
from noise import pnoise3
from voxel_world import VoxelWorld
from IPython.display import display, Image as IPImage # Jupyter notebook

display(IPImage(data=VoxelWorld.Animations.create_voxel_img(
    np.array([[[1 if pnoise3(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),
    random.choice(list(VoxelWorld.themes.keys())),
    resolution=10,
    viewing_angle=(random.randint(0, 90), random.randint(0, 90)),
    zoom=2.0,
    show_light_source=False,
    dark_bg=False
).getvalue()))

image

image

image

image

examples/sandworld.py

image

examples/light_source.py

download (1)

examples/jill_of_the_jungle.py

jill_of_the_jungle

examples/earth_tones.py

earth_tones

Mono-color themes

from voxel_world import VoxelWorld

world = VoxelWorld.show_themes() # Jupyter notebook only

image

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

voxel_world-0.0.3.tar.gz (10.7 kB view hashes)

Uploaded Source

Built Distribution

voxel_world-0.0.3-py2.py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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