Skip to content

Instantly share code, notes, and snippets.

@neonb88
Created August 11, 2018 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neonb88/3052f7a511e9030f83f8a7123dc72207 to your computer and use it in GitHub Desktop.
Save neonb88/3052f7a511e9030f83f8a7123dc72207 to your computer and use it in GitHub Desktop.
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