Apply the animation, update the skeleton's world transform, then adjust the bone's rotation, then update the skeleton's world transform again.
One way to set the rotation is to adjust the local rotation like this:
Bone bone = animation.skeleton.FindBone("front_upper_arm");
...
bone.Rotation += targetRotation - bone.WorldRotation.
Note this doesn't take into account any skewing, which happens by inheriting nonuniform scale or be using the Shear
tool.
You probably don't want to call FindBone
a lot, as it does string comparisons with all the bone names. This is true with any method named FindXxx
.
Another way to do this is to use single bone IK. With that, instead of setting the bone's rotation, you'd set the IK target's position where you want the bone to point.