pyrender_visualizer_1.py 1.0 KB

12345678910111213141516171819
  1. def render_point(self, at_index, p, scale=1.0, radius=1.0, color=[1.0, 0.0, 0.0]):
  2. if at_index >= len(self.pt_pool):
  3. # create enough to allow at_index to work
  4. for i in range(len(self.pt_pool), at_index + 1): # must include at_index too
  5. # get primitive first
  6. sphere_trimesh = trimesh.creation.icosphere(radius=radius, subdivisions=1)
  7. sphere_face_colors = np.zeros(sphere_trimesh.faces.shape)
  8. sphere_face_colors[:] = np.array(color)
  9. sphere_trimesh.visual.face_colors = sphere_face_colors
  10. sphere_mesh = Mesh.from_trimesh(sphere_trimesh, smooth=False)
  11. sphere_node = Node(mesh=sphere_mesh,
  12. name="sphere_" + str(i)) # , translation=np.array([-0.1, -0.10, 0.05]))
  13. self.scene.add_node(sphere_node)
  14. self.pt_pool.append(sphere_node)
  15. # okay now we know the node exists, just change it's position
  16. self.pt_pool[at_index].scale = [scale] * 3
  17. self.pt_pool[at_index].translation = p