Created
August 7, 2020 14:38
-
-
Save wkentaro/0e1a9c4fb08e36daf99db64368eb60ef to your computer and use it in GitHub Desktop.
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 trimesh | |
import numpy as np | |
voxel_size = 0.01 # 1cm | |
encoding = np.random.randint(0, 2, size=(32, 32, 32), dtype=bool) | |
colors = np.random.random((32, 32, 32, 3)) | |
transform = trimesh.transformations.scale_and_translate( | |
scale=voxel_size, translate=(0, 0, 0) | |
) | |
voxel_grid = trimesh.voxel.VoxelGrid(encoding=encoding, transform=transform) | |
geometry = voxel_grid.as_boxes(colors=colors) | |
# voxel_grid.show() | |
# geometry.show() | |
scene = trimesh.Scene() | |
scene.add_geometry(geometry) | |
scene.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment