Skip to content

Instantly share code, notes, and snippets.

@neonb88

neonb88/render.py

Created Aug 11, 2018
Embed
What would you like to do?
render `numpy` voxels in Blender
import bpy
import numpy as np
objs = bpy.data.objects
scn = bpy.context.scene
scene_objs = [
objs['Cube_transparent'],
objs['Cube_body']
# objs['sand'],
# objs['grass'],
# objs['water'],
]
voxel_data = np.load('/home/u/p/cat_1st_demo/render_bendich/_cartesian_model.npy').astype('int')
for x in range(voxel_data.shape[0]):
for y in range(voxel_data.shape[1]):
for z in range(voxel_data.shape[2]):
obj = scene_objs[voxel_data[x,y,z]].copy()
scn.objects.link(obj)
obj.location = (x*2.1, y*2.1, z*2.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment