Animation pivot point issues

Hi all!

I’m not sure if this is the right place to ask this question, as it is both scripting and Blender’s usage itself.

I’m writing my custom animations exporter, and I encountered a problem where root bone’s matrix_local had no translation (.to_translation() returned (0, 0, 0) vector), so in my game the animation was pivoting around object’s geometry center.
I tracked the issue to armature’s origin was set to root bone’s head - when I moved it to geometry center (with CTRL + SHIFT + ALT + C - the best shortcut ever) it got fixed in the game, but in Blender, when animation is played (ALT + A), or exported (with any exporter: .obj, .x, or my custom exporter) then the armature itself changes the position - even though the animation contains only rotation - there’s no translation nor scale included. The position is being changed to root bone’s head position.
I believe the problem could be tracked down to simply changing the scene frame, as when I move the timeline slider - it also happens (and my exporter, and other exporters too, I believe are changing the frames).

Here comes few questions of mine:

  1. Why does that problem with armature changing it’s location happening and how to fix it?
  2. If bone’s matrix had empty translation, then why did blender do the animation around the root bone and not armature’s center of geometry? No translation should mean the pivot is always (0, 0, 0), right? Just like it was happening in my game.
  3. Is it possible to manually specify object’s origin, rather than using CTRL SHIFT ALT C? Something like “Location” in properties window. I could use either interface or scripting for this.

And also I’d like to suggest modifying the documentation a little on Bone’s matrix_local, right now it says “4x4 bone matrix relative to armature”, but I think it should be something like “4x4 bone matrix relative to armature and it’s origin” (since it was the cause of my problem).

Thank you!