Skip to content

Proposed redesign of animation export

bsupnik edited this page Apr 17, 2015 · 2 revisions

This is a proposal for a refactor of the animation exporter that would simultaneously solve three issues:

  1. Incorrect export of armature-based animation - needed to provide an upgrade path from Blender 2.49->2.73.
  2. Incorrect export of object-based animation - needed to make the new object-based animation functionality work bug-free. (There are a number of bugs filed and caveats on this.)
  3. Inefficient export of animation (including the use of animations for static transforms and extra key-framed animations).

The key refactor is to move generation of the animation commands out of the exporter and into the x-plane objects themselves. This would allow for:

  • Special casing of the animation generated depending on the -type- of object and
  • Specific close examination of the particular animation source data (e.g. the armature axis or type of interpolation on an object) to generate the right animation.

This would mean that armature axis-angle rotations could be generated directly from bones, and object-based animations could follow the euler order specified in Blender (or generate an axis-angle if desired).

In this scheme:

  • An XPlaneBone is an animation context to which rendered elements (meshes, lights) can be attached.
  • It has zero or one parent bones - if there is no parent bone, the bone is effectively anchored to the global coordinate system.
  • It is capable of outputting the transformation OBJ8 code to go from its parent bone to its bone.
  • An XPlaneBone may be built off either of:
  1. An actual Blender bone/pose-bone in the case of armature-based animation or
  2. Any Blender "Object"-derivative (light, armature, mesh, empty) that can be directly key-framed.

Note that in the case of an animated armature with an animated bone, two X-Plane bones are generated.

Bake Matrices

There exists a bake matrix from any exportable object (mesh, light) to any bone that it is parented to. There also exists a bake matrix from any bone to a child bone, and there exists a bake matrix from the world to an unparented bone.

These bake matrices represent static coordinate system changes between elements that do not need to generate transforms.

There are exceptional two cases where static transforms must be generated:

  1. Since rotations are always about the origin in OBJ8, if an armature rotates around the origin, but a bake matrix contains a translation, then the bake matrix will cause a static translate to be output. This is not really a case of more animations - we can think of a single static pre-translate as being implicit in all rotations; it would have appeared if the armature happened to rotate around an arbitrary point before baking.
  2. Lights are not bake-able, so the lamp export code needs to take the bake matrix and output a rotation to the correction orientation.

#Export state-change efficiency

Given all else equal, we want to sort animated meshes by their bones, with the sort order preferring parent bones to child bones. The result will be the minimum number of actual animation commands to produce the correct coordinate systems.