Is there any way to query bone roll axis direction?

Is there any way to query the direction in which the bone roll axis is pointing? That is, to access the information which is displayed when the “Draw Axes” toggle is selected for an Armature. If not, is there any hope that this might be added to the API at some point? I seem to keep running up against bone roll problems, but every way I can think of to compensate for these problems eventually runs up against all of the arbitrary factors involved with bone roll. This could be remedied somewhat if the roll axes value can be found.

Does anyone know anything about this?

You could get a vector
say (1,0,0) and multiply it by the bones matrix and that would point allong the bones X axis, including the roll since the matrix includes the roll.

So the vector you suggest would be a controlled value to specify an axis? When dealing with matrices, my main problem is trying to interpret the data any matrix function gives me. I read up on matrix math a few weeks ago, but the reference materials I could find didn’t take me much further than identity matrices, matrix multiplication, and the value of inverse matrices.

Sorry to be a bother, Cambo, but can you clarify your response for me at all? Or point me toward any resource which will better educate regarding matix functions?

And when you mention roll, you’re not referring to the roll that we can query or set with bone.roll, right? I’m not concerned about the roll value that Blender allows us to set, but the “intrinsic roll”, which is, I assume just a characteristic of the bone as a vector. Um. Is that what you’re saying?

It’s a drag, being one of the slow kids. :frowning:

Dont wory about being slow :wink: I only understand matrix trough trial and error and messing about- reading math docs dosent always help practicaly.

Of course others may correct me here but I think this will work.

I dont quite understand your definition of roll- This is the direction the bones Y axis would point in the 3d view if draw axis were enabled.

heres the psudo code.

y_dir= Vector(0,1,0)
y_dir= y_dir*pose_bone.postMatrix.rotationPart() # poseMatrix is worldspace

now y_dir points at the bones rolled y direction since the posepatrix includes the roll

Thanks, Cambo. That helps.

I guess I should try to clarify my statements about bone roll, since I carry on about the matter so much. :slight_smile:

If you create a one-bone armature, then turn on “Draw Axes”, the bone’s y (twist) axis should be pointing “up” relative to the camera view in which it was created. The z axis pointer should point forward. Don’t alter the bone’s roll settings at this point. If you then grab the bone’s tail and start dragging it around, the drawn axes shift around as the bone’s y axis direction changes. The direction in which the axes point (specifically “z”, since that seems to be the point of reference when “correcting” bone roll to be sure that things point the right way) is the information I’m after. I’ve been calling this the “intrinsic roll” of the bone. It results from setting head and tail positions, and the “bone roll” which we set via Blender interface or Python seems to compensate for this value. I’ve read of vectors having a “roll” characteristic, and I assume the “intrinsic roll”, then, might be the roll of the bone as vector. I think I’ve seen this information in a bone’s bonespace matrix (expressed as euler), but the values I’ve seen also seem oddly inconsistent sometimes.

So “intrinsic roll” is the variance in roll axis direction (relative to the worldspace, I assume - or maybe the armaturespace?) which results from the relationship between head and tail. “Settable roll” is the roll value that we set to compensate for intrinsic roll, to make the armature’s bone rotation orders consistent. Intrinsic roll is visible when settable roll is zeroed and the axes are drawn. That’s how I’ve been thinking about it. Intrinsic roll is in the rest matrix somewhere, but it keeps hiding from me. :slight_smile: All of this relates to what they call “rotation order” in Poser-land.

I’m trying to work with this in a couple of ways (and failing, thus far, unfortunately). When flipping or symmetrizing an armature’s pose across x, it becomes important that each bone and its symmetrical counterpart have their bone roll axes pointing in the same direction - or have these directions corresponding in a way which will create a symmetrical flip. But I’ve seen at least one armature which has the axes pointing all over the place on the legs when bone roll (the type we can set) is zeroed. To symmetrize a pose for such an armature I either need to be able to compare the roll axis directions for the two symmetrical bones and compensate or I need to correct the settable bone roll setup for the armature. (Or find a way to remove bone roll from the equation altogether, as your .bvh code allows for poses in general; the same process hasn’t worked for symmetrizing.)

So I’m trying to find a way to compensate for or automatically alter and correct bone roll asymmetry in otherwise symmetrically-structured armatures. I assume I could find this “intrinsic roll” and use it to find either the corrected settable bone roll for the armature or to create symmetrical pose settings when roll directions are incompatible.

So maybe I’m asking the wrong question. Perhaps I should ask how to work with a rest matrix to overcome or fix bone roll issues. Hmm. Am I “barking up the wrong tree”? Woof. :slight_smile:

Still all muddled and obscure, right? Sorry. Anyway, I’m working on it, and I think your post helps. Thanks, Cambo. :slight_smile: