Update bone position after programatic animation

Hi,

I have a model with a skeleton. I’m interested in retrieving the position of the skeleton’s bone. This what I’m using:

control.getSkeleton().getBone(boneIndex).getModelSpacePosition()

The problem that I’ve noticed is that after I programmatically change the pose of the model/skeleton (e.g. rotate certain bones), the above value won’t reflect the new position unless the next frame has been rendered. Is there a way to tell the geometry/skeleton to refresh the position of the vertices/bones right after a modification?

Thanks

Lucas

How can it be that if you change them programmatically you don’t know what the final position is? oO

Say for example that I rotate the hip (or any other bone that contains several children). This will make the head, arms, hands, etc move to a new position. I’d like to get their new position without having to compute it manually. I see that the position is updated, but only after a new frame has been rendered. Any way to force it to re-compute it right after the transformation?

Maybe this will help:

bone.setUserControl(true);
bone.setUserTransformsWorld(translation, rotation);

or

bone.setUserTransforms(translation, rotation, scale);

Yes, that’s what I’m doing to rotate the parent bone. My question was how to update the position of the children.

I finally worked it out. I needed to call updateWorldVectors() for all the children. Like this:

bone.setUserControl(true);
bone.setUserTransformsWorld(translation, rotation);
updateWorldVectorsRecursive(bone);

private void updateWorldVectorsRecursive(Bone bone) {
    bone.updateWorldVectors();
    for (Bone child : bone.getChildren()) {
        updateWorldVectorsRecursive(child);
    }