title: what space is this Matrix in?
body: <p>In Blender 2.6 API, PoseBone is used for animating a bone. PoseBone.matrix is one way to do that. API says PoseBone.matrix is in "object space".</p>
  
  <p><a href="http://www.blender.org/documentation/blender_python_api_2_63_5/bpy.types.PoseBone.html#bpy.types.PoseBone.matrix" rel="nofollow noreferrer">http://www.blender.org/documentation/blender_python_api_2_63_5/bpy.types.PoseBone.html#bpy.types.PoseBone.matrix</a></p>
  
  <p>PoseBone.matrix is nothing I've seen at all.
  I still can't get my animation importer working.
  What's the deal with PoseBone.matrix? In Blender 2.4 API there were two matrices: one in local space, one in armature space.</p>
  
  <p>But the new PoseBone.matrix is neither! It's not a local matrix: </p>
  
  <p><img src="https://i.stack.imgur.com/W4rnr.png" alt="enter image description here"></p>
  
  <p>Position isn't local, it's global.</p>
  
  <p>But rotation 
  <img src="https://i.stack.imgur.com/1uYCu.png" alt="enter image description here"></p>
  
  <pre><code>&lt;Euler (x=1.5708, y=-0.7854, z=-0.0000), order='XYZ'&gt; 
  </code></pre>
  
  <p>is.</p>
  
  <p>So what is this "object space" that the API says PoseBone.matrix is in?</p>
  
  <p>I'm trying to assign my armature-space matrices to a hierarchial armature and I can't get them right.</p>
  
  <p>I tried decomposing the matrices I have, undoing parent rotations then recomposing the matrix again before setting it as "PoseBone.matrix".
  It just doesn't work. </p>
  
  <pre><code>oldmatrix = myMatrix
  loc, rot, scale = oldmatrix.decompose()
  
  #rot = rot * pose.bones[bonename].parent.rotation_quaternion.conjugated()
  for i in pose.bones[bonename].parent_recursive:
     rot = rot * i.conjugated()
  
  newmatrix = rot.to_matrix().to_4x4()
  
  newmatrix[0][3] = loc.x
  newmatrix[1][3] = loc.y
  newmatrix[2][3] = loc.z
  
  pose.bones[bonename].matrix = newmatrix 
  </code></pre>