Hi There,
I’m using controlJoints from my egg files to attach “arrows” to other objects and visibly tie them together. This seems to work. I also use the CollisionHandlerQueue and CollisionTraverser to detect clicks and mouseovers of my objects. The objects the arrows connect work as expected with mouse interaction, but, the “arrows” do not work with the traverser. In fact, the traverser finds them at their un-moved location, even though they are not rendered there. I’v also noticed that the arrows disappear from the screen when the camera no longer includes the origin (which is where the arrows “start” before they are connected to their objects). I’m assuming I’m mis-using the controlJoint somehow, or perhaps have not completed the linkage correctly… here is the code I use to create the joints:
class ConnEdge(Model):
"""The class which implements the edge."""
# @funlog
def __init__(self, uid, model, app, connection, space="nord"):
"""Call the super constructor and attaches the model bones."""
super().__init__(uid, model, app, tag='clickable', space=space)
self.connection = connection
self.tgtEnd = self.model.controlJoint(None, "modelRoot", "tgtBone")
self.srcEnd = self.model.controlJoint(None, "modelRoot", "srcBone")
# self.data.listJoints()
# @funlog
def setSrcPos(self, pos):
"""Set the position of the source bone."""
self.srcEnd.setPos(pos)
# @funlog
def setTgtPos(self, pos):
"""Set the position of the target bone."""
self.tgtEnd.setPos(pos)
# @funlog
def updateConnection(self, srcPos, tgtPos):
"""Update the positions of this edge."""
quat = Quat()
vec = tgtPos - srcPos
look_at(quat, vec, Vec3.up())
self.srcEnd.setHpr(quat.getHpr())
self.setSrcPos(srcPos)
vec = srcPos - tgtPos
look_at(quat, vec, Vec3.down())
self.tgtEnd.setHpr(quat.getHpr())
self.setTgtPos(tgtPos)
def __init__(self, uid, name, app, tag='clickable', space="nord", hoverable=True):
"""The constructor."""
super().__init__()
self.uid = uid
self.name = name
self.app = app
self.onMappedFuncs = []
# self.physics = BulletRigidBodyNode(uid)
# self.physics.setMass(1.0)
self.model = mm.load_model(name, space)
self.space = space
# bounds = self.model.getTightBounds()
# if bounds is not None:
# radius = (bounds[1] - bounds[0]).length() / 3.0
# else:
# err("No size data available for : {}:{}".format(name, uid))
# radius = 0.01
# shape = BulletSphereShape(radius)
# self.physics.addShape(shape)
self.data = cm.cwc().attachNewNode(uid)
self.model.reparentTo(self.data)
self.data.reparentTo(cm.cwc())
self.data.setScale(1.0, 1.0, 1.0)
self.data.setTag(tag, uid)
if hoverable:
self.data.setTag('hoverable', uid)
# self.world = cm.cur_world()
# self.world.attach(self.physics)
self.tooltip = Tooltip()
self.tooltip.add_updater(self.update_tooltip)