I have written a code that makes an actor pick an object by reparenting that object to the actor’s left hand joint. I use exposeJoint to get a reference to a joint nodepath as in the manual and reparent my model to that nodepath. When I call getChildren on the joint nodepath I find my object attached to the hand joint. The problem is that when I call expose joint a second time to get a reference to the same joint node path and then call get children on that joint node, I find that the joint has no children. I can’t understand that behavior.
here is a code snippet for demonstration
self.c2.model.reparentTo(self.render)
joints = self.c2.model.getJoints(None,"*LeftHand")
print(joints)
print(joints[0].get_name())
self.joint_left = self.c2.model.exposeJoint(None,'modelRoot',joints[0].get_name())
self.cup = self.loader.load_model(mp)
self.cup2 = self.loader.load_model(mp)
self.cup2.reparentTo(self.joint_left)
self.cup.reparentTo(self.joint_left)
self.cup.setEffect(CompassEffect.make(self.render, CompassEffect.PScale))
self.cup2.setEffect(CompassEffect.make(self.render, CompassEffect.PScale))
for child in self.joint_left.getChildren():
print(child)
if child.getParent()==self.joint_left:
print("hi")
self.joint_left = self.c2.model.exposeJoint(None,'modelRoot',joints[0].get_name())
for child in self.joint_left.getChildren():
print(child)
if child.getParent()==self.joint_left:
print("hi")