def preview_ray_tracing(meshes, points): scene = pyrender.Scene() for m in meshes: scene.add(pyrender.Mesh.from_trimesh(m)) sm = trimesh.creation.uv_sphere(radius=0.02) sm.visual.vertex_colors = [1.0, 0.0, 0.0] tfs = np.tile(np.eye(4), (len(points), 1, 1)) tfs[:,:3,3] = points pm = pyrender.Mesh.from_trimesh(sm, poses=tfs) scene.add(pm) pyrender.Viewer(scene, use_raymond_lighting=True)
def preview_mesh(m): scene = pyrender.Scene() scene.add(pyrender.Mesh.from_trimesh(m)) pyrender.Viewer(scene, use_raymond_lighting=True)
def preview_mesh(m, original_mesh=None): scene = pyrender.Scene() scene.add(pyrender.Mesh.from_trimesh(m)) if original_mesh is not None: scene.add(pyrender.Mesh.from_trimesh(original_mesh)) pyrender.Viewer(scene, use_raymond_lighting=True)
# try inverted # get initialized mesh # subdiv and do shrink wrap # keep vertex and project it # new_vertices = quad_mesh.subdivide() # print(len(new_vertices)) # print(len(quad_mesh.vertices)) # quad_mesh.project_vertices(new_vertices, np.repeat(0.3, len(new_vertices))) # quad_mesh.subdivide() # quad_mesh.subdivide() # quad_mesh.subdivide() # print(new_vertices) tri_mesh = quad_mesh.get_tri_mesh() # Preview mesh = pyrender.Mesh.from_trimesh(tri_mesh) pm = pyrender.Mesh.from_points(points) scene = pyrender.Scene() # scene.add(pyrender.Mesh.from_trimesh(target)) scene.add(mesh) # scene.add(pm) pyrender.Viewer(scene, use_raymond_lighting=True)
resolution_multiplier=rm) d_left, s_left = build_depth_surface(mesh1, bounding_box, direction='+x', znear=0.01, resolution_multiplier=rm) d_right, s_right = build_depth_surface(mesh1, bounding_box, direction='-x', znear=0.01, resolution_multiplier=rm) if showDepthImagePreview: for dmap in [d_top, d_bottom, d_front, d_back, d_left, d_right]: plt.imshow(dmap, cmap=plt.cm.gray_r) plt.show() if showIsolatedDepthSurfacePreview: for s in [s_top, s_bottom, s_front, s_back, s_left, s_right]: preview_mesh(s) depth_preview_scene = pyrender.Scene() depth_preview_scene.add(pyrender.Mesh.from_trimesh(s_top)) depth_preview_scene.add(pyrender.Mesh.from_trimesh(s_bottom)) depth_preview_scene.add(pyrender.Mesh.from_trimesh(s_front)) depth_preview_scene.add(pyrender.Mesh.from_trimesh(s_back)) depth_preview_scene.add(pyrender.Mesh.from_trimesh(s_left)) depth_preview_scene.add(pyrender.Mesh.from_trimesh(s_right)) pyrender.Viewer(depth_preview_scene, use_raymond_lighting=True)