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