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
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')
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()
Randomly generated worlds
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()))
examples/color_matrix/sand_world.py
examples/lighting/light_source.py
examples/color_matrix/jill_of_the_jungle.py
examples/color_matrix/earth_tones.py
Mono-color themes
from voxel_world import Volume
world = Volume.show_themes() # Jupyter notebook only
Project details
Release history Release notifications | RSS feed
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.1.3.tar.gz
(20.1 MB
view hashes)
Built Distribution
Close
Hashes for voxel_world-0.1.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8852ddab397e66c1afa8748ffd6a0c8ef59074a055f7008f0a6221f2105d5d3 |
|
MD5 | 83a11287476a2aad36c44802841f8f05 |
|
BLAKE2b-256 | 9c2264584fd191ab9b4502b4adeedc44944586f95e8ec47c4a266a32f547211b |