[Bf-committers] Expansion of pinBone functionality - looking for more advice

Roland Hess me at harkyman.com
Tue Aug 31 04:05:51 CEST 2004

Okay. I have pinBone working, but it only works for root bones at the 
moment. (Briefest of rundowns: pinbone calculates the difference between 
the corresponding bones in two NLA strips and modifies key values 
on-the-fly in the later/lower strip so that the animation lines up 
without undesirable sliding). I want to expand it to be able to be used 
with any bone in an armature. Currently, I'm using get_pose_from_action 
to retrieve the pose from the given action, and then using the ipo data 
(in quat, loc, size format) from the particular bone channel in that 
pose to do my calculations. (quat/loc/size is used because it is how the 
info is dealt with in do_all_actions, the existing Blender function for 
evaluating and applying NLA strips).

That was great while I was getting things working in other areas, but 
now, the limitation is that get_pose_from_action only returns useful 
info for root bones. What I need to do is to get the final object space 
quat/loc/size values for any given bone in a given action at a given 
frame. I already know about where_is_bone_time, and make_boneMatrixvr, 
but I'm operating under some unusual constraints, and they will not 
work. The constraint, of course, is that this information will be used 
in quat/loc/size format. Unless someone can point me to a function that 
already does this, I'm writing my own.

The structure of the main recursive function to do this is not a 
problem. Pseudocode:

find_bone_pos (quat, loc, size, pinbone) {
    if (!pinbone->parent) { return pinbone->quat,
       pinbone->size) } else {
    find_bone_pos (tquat, tloc, tsize, pinbone->parent)
    ...magic math...
    return tquat, tloc, tsize

The problem, obviously, is the ...magic math... section. Anyone want to 
chip in with the math for calculating the quat/loc/size from the parent 
bone's values and the active bone's values? Whatever formats (matrix, 
etc.) are used inside ...magic math... are of little consequence to me, 
but the output cannot be in matrix format -- it must be quat/loc/size. 
Do I need to involve bone heads and tails (I'm suspecting I do)?

You all have been a great help so far. Let's hope my luck holds out again.


Roland Hess

More information about the Bf-committers mailing list