12345678910111213141516171819202122 |
- def render_capsule(self, at_index, p, Q, length, scale=1.0, color=[1.0, 0.0, 0.0]):
- if at_index >= len(self.cap_pool):
- # create enough to allow at_index to work
- for i in range(len(self.cap_pool), at_index + 1): # must include at_index too
- # get primitive first
- sphere_trimesh = trimesh.creation.capsule(height=1.0, radius=1.0, count=[8, 8])
- 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="capsule_" + str(i)) # , translation=np.array([-0.1, -0.10, 0.05]))
- self.scene.add_node(sphere_node)
- self.cap_pool.append(sphere_node)
- # okay now we know the node exists, just change it's position
- self.cap_pool[at_index].scale = [0.1, 0.1, length]
- self.cap_pool[at_index].translation = p
- self.cap_pool[at_index].rotation = Q
- # print("Q: " + str(Q))
|