The class I've created thus far:
Code: Select all
class DragTracker(Tracker):
"""
Customized wire tracker
"""
def __init__(self, points):
"""
Constructor
"""
self.line = coin.SoLineSet()
self.line.numVertices.setValue(len(points))
self.coords = coin.SoCoordinate3()
self.transform = coin.SoTransform()
self.update(points)
Tracker.__init__(
self, children=[self.coords, self.line, self.transform], name="DragTracker"
)
self.node = self.switch.getChild(0)
self.draw_style = self.node.getChild(0)
self.color = self.node.getChild(1)
self.color.rgb = (0.0, 0.0, 0.0)
self.on()
def update(self, points):
"""
Update
"""
if not points:
return
self.line.numVertices.setValue(len(points))
for _i, _pt in enumerate(points):
self.coords.point.set1Value(_i, list(_pt))
def set_placement(self, placement):
"""
Transform the tracker by the passed placement
"""
vec = placement.Base
self.transform.translation.setValue(tuple(vec))