I usually would not post on small things like this, however a lot if of people want to do fun stuff with armatures and python, and this area us nutritiously tricky to work in.
Malifco showed me a script he was working on where he wanted to set the pose bone location, but he couldn’t figure out the matrix math (I dont blame him!) anyway- copying some code from blenders internals did the trick!
now you can do stuff like…
pose_bone.poseMatrix = someOb.matrixWorld
Just remember that this sets the loc/size/rot - if you have constraints applied, these will be evaluated ontop of the new loc/size/rot.
This kind of thing could be useful in all sorts of areas, especially if you want to move bones in relation to other objects and then key the poseBone.
This is in SVN so youll need to wait for a new build or compile yourself.
Can this be used in the game engine?
nope, only in blender for animation tools etc.
Hey Campbell! I just found this thread! It is a life saver (I fail Blender matrix math). almost…it kinda works with 2.45.16. The issue I have is that the first 10 frames are screwy, but then it settles down, as if some solver is getting better results as time goes by, then hiccups at frame 50. This blend fileshould show you. Please run the script, it makes a duplicate object, then bakes the bones. The module bakeBone has my bad matrix math commented out and your wonderful pbone.poseMatrix=rbone.poseMatrix statement, where pbone is the bone I want to set and rbone is the reference bone.
Help? either in my bad matrix math, or …
ideasman42: I believe the nature of the bug is that the rotation of the parent bone is being accumulated during interpolation, so that the poseMatrix over-rotates the bone in the assignment:
during non-keyed frames. When it hits a key, the poseMatrix and bone jump back to where they should be.