hello everyone!
I’m trying to add variance to my characters by stretching and squashing certain bones withing reason (also for a character creator!). I’m having troubles stretching one bone while keeping child bones visibly unaffected
here’s my example: Babylon.js Playground
a bit exaggerated, but notice how the chest stretches and stringifies the arms with it? I’d like just the chest to stretch, and for the arms to remain the same size.
Hello
The armature is done in a way that indeed, children inherit transforms from parents.
I see in your code that you tried a counter scale on the children :
sk?.bones[2].children.forEach(c => {
c.getTransformNode().scaling.copyFrom(BABYLON.Vector3.One().divide(targetNode.scaling))
})
And to me, this is the good approach.
By the way, in fact it works :
Without the counter scale, everything shrinks
With the counter scale, the head stays OK :
The reason why it doesn’t work on the arms, is that the bones are rotated 90° (compared to the head. Head is from bottom to top, arms arm from center to extremety). Your counterscale is affecting the arms in the wrong direction, as you can see from the side :
So solve this, you just need to add a condition, since head (joint20
) should receive a counterscale on X axis, while arms (joint13
and joint18
) should receive a counterscale on Y axis :
skeleton.bones[2].children.forEach(c => {
if(c.name=="joint20"){
c.getTransformNode().scaling.set(counterScale, 1, 1);
} else if(c.name=="joint13" || c.name=="joint18"){
c.getTransformNode().scaling.set(1, counterScale, 1);
}
})
Playground
++
Tricotou
2 Likes
I did end up doing exactly this! but it gets so inaccurate when bones are not at right angles
ex: in my own model, the foot bone is ~135° down from the calf bone, so the counter-scaling is not at all clean. plus, for bones with multiple children, you see how tedious this can get
I wonder if we can scale the child bones relative to the parent’s space? that way the conter-scaling should work for all bones?