Attach() problem with multi-part actors

Hey all,

So I have a model with the head and body separate (due to the art pipeline I’m grabbing assets from), and would like to combine the two as a multi-part actor. However, I’m having trouble getting the Attach() call to work properly:

I imported the two models and used egg-optchar to expose a the neck joint on both (“jtNeck”). Here is the code written to create the actor:

def loadMulti(self):
        self.Star = Actor(
            {"head":"opt/starHead",
            "body":"opt/starBody"},
            
            {"head":{"tap":"anim1Star"},
             "body":{"tap":"anim1Star"},
             "head":{"talk":"starHeadAnim1.egg"}
        })
        
        self.Star.attach("head","body","jtNeck")
        
        self.neck1 = self.Star.find("**/__Actor_head/jtNeck")
        self.neck2 = self.Star.find("**/__Actor_body/jtNeck")
        print("HEAD: ", self.neck1)
        print("BODY:", self.neck2)
        self.Star.ls()
        
        self.Star.setScale(1,1,1)
        self.Star.reparentTo(render)
        self.Star.setPos(0,0,0)

And here is the response in the console confirming both jtNeck joints were recognized:

It seems that it’s just attaching the head to the body’s joint at the head’s origin rather than at the head’s neck joint.

Any ideas how I can fix it?

I can’t tell the parenting from your post, since without the code tags the indentations are lost.

One question that leaps to mind is whether you have stripped the neck animation off the head. Since the head will be parented to the neck joint from the body, it’s important that the head not contain any neck animation of its own: that is, if you load up the head and play it by itself, it should be sitting on the ground, at the origin, and not moving. If it’s bobbing around at 5 feet or so, you’ve still got the neck animation, and you’ll end up doubling that animation. Use egg-topstrip to remove the animation if necessary.

If you can load, say, smiley.egg, and parent him by hand to your exposed neck joint, and he shows up on the shoulders, then the neck joint on the body is good.

Finally, if you can parent the head to the neck joint by hand and it comes out right, then you’re probably in a good situation, and something in the Actor code is getting it wrong.

If all else fails, if you post your egg files where I can download them, I may be able to give you more specific advice.

David

The head is holding still but it’s origin is well below the neck (so that if I setPos(render,0,0,0) the head and body independently the head will be in the “correct” position to the head).

However, the way the multi-part animation manual is written, I thought the head’s joint that was in common with the body would be attached to the body’s joint (so that the head’s jtNeck would be attached to the body’s jtNeck). If that is not the case, is it just the .egg’s origin attached to the joint?

Is there any examples of egg-topstrip?

Yep, that’s what it is. And that’s the purpose of egg-topstrip: to remove the animation from the head’s jtNeck, so that its origin will be the appropriate place to attach the joint.

I don’t know if there are any examples of egg-topstrip, but (like almost any Panda command) you can get a brief introduction with “egg-topstrip -h”.

David