LetterRip
(LetterRip)
1
Does anyone have a function, or could post one that does the following?
Given an armature, a bone, an action and a framenumber it will return the local space matrix of the bone for the given action and frame number?
def getBoneLocalSpaceMatrixAtFrame(armature, bone, action, frameNumber):
return boneLocalSpaceMatrix
Harkyman needs such a function in order to continue working on his blenderpeople stuff.
Thanks,
LetterRip
Ben
(Ben)
2
def getBoneLocalSpaceMatrixAtFrame(armature_obj, bone, action, frameNumber):
Blender.Set('curframe', frame)
act = Blender.Armature.NLA.CopyAction(action)
act.setActive(armature_obj)
boneLocalSpaceMatrix=bone.getRestMatrix('bonespace')
return boneLocalSpaceMatrix
…I think this works …maybe :-?
Ben
LetterRip
(LetterRip)
3
Hi Ben,
Here is a test blend and script
http://wiki.blender.org/pub/Blenderdev/SculpMesh/testbonematrix.blend
what I think needs to happen is that all of the matrixes from the root bone to the target bone need to be multiplied.
LetterRip
LetterRip
(LetterRip)
4
hmm would this be it?
def getBoneLocalSpaceMatrixAtFrame(armature_obj, bone, action, frameNumber):
Blender.Set('curframe', frameNumber)
act = Blender.Armature.NLA.CopyAction(action)
act.setActive(armature_obj)
boneLocalSpaceMatrix=bone.getRestMatrix('bonespace')
if bone.hasParent():
boneLocalSpaceMatrix *= getBoneLocalSpaceMatrixAtFrame(armature_obj, bone.getParent(), action, frameNumber)
return boneLocalSpaceMatrix
Ben
(Ben)
5
…if you want the distance of the bone from root
can use the :
bone.getRestMatrix()
without the (‘bonespace’).The defalt is (’‘worldspace’)
Ben
LetterRip
(LetterRip)
6
Yeah figured that out last night,
thanks though.
It is also mislabeled, since that is the objects localspace, not worldspace coordinates.
LetterRip