[Bf-committers] Armatures for beyond Release 2.4
Brecht Van Lommel
brechtvanlommel at pandora.be
Fri Dec 23 17:59:44 CET 2005
Hi Thomas,
Thomas H. Hendrick wrote:
> Gilbert, Joseph T. wrote:
>> I think that what the python api could create some 'fudges' to convert a
>> transformation matrix and/or a quat/loc into the vector_head,
>> vector_tail, roll This way you could add methods like setMatrix(),
>> setQuat(), setLoc(), setLength() to the armature bone.
>
> I think I understand the Blender Source well enough to write and submit
> a patch for something like this, but I don't think I fully understand
> the Mathematics behind it. If someone could give me a general run-down
> of the equations that would be needed, I could probably make the code
> happen.
This sort of conversion happens in a few places in the blender source,
although never exactly the same as needed here it seems.
in blenkernel/intern/armature.c :
vec_roll_to_mat3 does the opposite of what you need
in b_bone_spline_setup around line 476-481 the roll is computed
So assuming you have a quaternion, a bone length and a bone head,
you can do this:
- convert quaternion to 3x3 matrix
- the 'direction' vector of this rotation is the second column of the matrix.
(in blender's code this is simply mat[1])
- the bone tail then is bone head + direction * bone length.
- the roll you can compute exactly the same as in in b_bone_spline_setup:
- make a rotation matrix with vec_roll_to_mat3 using only the direction
- compute the difference of this new matrix with the original matrix
- roll = atan2(diff[2][0], diff[2][2]);
Cheers,
Brecht.
More information about the Bf-committers
mailing list