marian42 / mesh_to_sdf

Calculate signed distance fields for arbitrary meshes
https://pypi.org/project/mesh-to-sdf/
MIT License
1.02k stars 108 forks source link

can't even run through the sample code... #32

Open yawning-lion opened 2 years ago

yawning-lion commented 2 years ago

thanks a lot for the great library! I try to run sample code in terminal of ubuntu, but I just can't get proper result. 86411d7aaba8b428954615532ecece9 ''' from mesh_to_sdf import mesh_to_voxels

import trimesh import skimage

mesh = trimesh.load('chair.obj')

voxels = mesh_to_voxels(mesh, 64, pad=True)

vertices, faces, normals, _ = skimage.measure.marching_cubes(voxels, level=0) mesh = trimesh.Trimesh(vertices=vertices, faces=faces, vertex_normals=normals) mesh.show() ''' 2cbba96d0562cabbc6b0900ce35b0e1 ''' from mesh_to_sdf import sample_sdf_near_surface

import trimesh import pyrender import numpy as np

mesh = trimesh.load('chair.obj')

points, sdf = sample_sdf_near_surface(mesh, number_of_points=250000)

colors = np.zeros(points.shape) colors[sdf < 0, 2] = 1 colors[sdf > 0, 0] = 1 cloud = pyrender.Mesh.from_points(points, colors=colors) scene = pyrender.Scene() scene.add(cloud) viewer = pyrender.Viewer(scene, use_raymond_lighting=True, point_size=2) ''' I'm totally a noob there, and I'm wondering what's wrong with it. someone can help? I'll greatly apprieciate your help😭