Hello!
I have a rigged model that I’ve converted into an egg. The model skeleton has bones for each section of a 3 segmented leg. The top bone of each leg is on the top level of the armature tree, with the subsequent sections being children of the section above it.
This makes re-positioning/animating the leg geometry much easier, as the parent-child relationship carries over into Panda3d (ie when the top bone is rotated the lower two bones stay attached to the end of the top bone with their local rotation intact). Here’s what listJoints() returns:
skel
<skeleton>
headBone hpr 180 0.215891 180 trans -0.044719 1.62412 -0.237554
leftTopBone hpr 180 -26.7939 -180 trans 0.364471 1.53504 -0.440333
leftMidBone hpr 180 71.794 0.000194814 trans 0 0 -0.515918
leftBottomBone hpr 0 74.9315 0 trans 0 0 -0.649599
rightTopBone hpr 180 -26.7939 -180 trans -0.435863 1.53504 -0.440333
rightMidBone hpr 180 71.794 0.000194814 trans 0 0 -0.515918
rightBottomBone hpr 0 74.9315 0 trans 0 0 -0.649599
My problem is in attaching other objects to these joints. What I’m trying to do in particular is attach Bullet Physics nodes to each leg part for collision detection. unfortunately, this only works for bones in the top level of the hierarchy. You can see in the tree listing above that the “trans” values for the mid and bottom bones are relative to their parent (I think this is part of the problem).
Attaching to these bones correctly sets the rotation, but the position is lost and the physics nodes end up at the origin of the actor the bone tree is a child of. Below is a snippet of what i’m trying to do. This is code from a function that is supposed to attach a physics node to the bone passed into it.
#bone is one of actor.controlJoint("rightMidBone") etc.
shape = BulletBoxShape(Vec3(.05,.05,.3))
node = BulletGhostNode(self.name + pname)
np = bone.attach_new_node(node)
np.node().add_shape(shape)
np.node().set_kinematic(True)
np.reparent_to(bone)
Like I explained above, this code works for the top-level bones, but the middle and bottom leg bones don’t provide the bullet node pointer with correct translational information. I’m thinking there should be a way to do this without manually entering in the position of the lower leg segments to position the bullet nodes for those segments. Can anyone offer wisdom on this? Am I attempting a bad practice?
Let me know if I can provide any other information, and thanks in advance for your time!