Attach objects to joints

Hello,
I’m trying to reparent an object ‘head’ to the ‘head’ joint of an Actor using this code:

self.headJoint = self.exposeJoint(None,'modelRoot','mixamorig:Head',localTransform=True)
self.head = loader.loadModel('resources/characters/head.bam')#a static model(not rigged)
self.head.reparentTo(self.headJoint)

the fact is that it seems to do nothing! I’m sure that the model is big enough to be visualized correctly(I tried to reparent it to render and it worked), I’ve tried to print both headJoint’s and head’s positions and they were the same… What am I doing wrong? The only example I found in the samples folder(looking-and-gripping) does the same thing and it works…

In this case, have you tried exposing the joint without “localTransform” being set?

Yes, but nothing happened. I also tried to set its position passing ‘render’ as first parameter and then camera.lookAt(thatPosition) but I can’t see anything…
The fact is that I’m completely clueless on how to debug this :-/

What I might suggest is to figure out roughly what the expected location is, checking it by placing there a marker (being simply an arbitrary model). Then attach your intended object to the joint, and print out its position relative to “render” (i.e. via a call to “getPos(render)”). Compare the printed location with the expected location, and see whether they’re close.

Another thought might be to print the attached object’s scale relative to “render”, just in case there’s a scaling factor sneaking in somewhere in the hierarchy (perhaps via one of the joints in the armature).

Yes, you’re right: a nasty scaling factor. I’ll try to remove it from blender(but how to do it?).

Thank you so much! :slight_smile:

1 Like