Created
August 11, 2018 16:19
-
-
Save neonb88/3052f7a511e9030f83f8a7123dc72207 to your computer and use it in GitHub Desktop.
render `numpy` voxels in Blender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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