Zloyded12 / blender-smd

Automatically exported from code.google.com/p/blender-smd
0 stars 0 forks source link

Animation support #1

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Converting Source bones to Blender bones (and vice versa) is proving very 
difficult. The major differences are:

  * Source bones are 1D points with rotation; Blender bones have a head and a tail
  * Source bones point down the Z axis; Blender bones point down the Y axis
  * Source is right-handed; Blender is left-handed

These create several problems:

  * The underlying complexity of turning a global vector into a local rotation. This has a solution that someone with enough understanding of 3D maths will hopefully find one day.
  * Import compatibility. For a model to remain compatible with existing animations it must retain the exact some bone rotation values. This prevents bones from being connected to their parents, as doing so nearly always affects rotation.
  * Axis difference. Either bones tails stick out at right angles (Z up) or we go with Blender and confuse anyone who tries hand-editing animations (Y up). The actual direction that bones face after export isn't a problem, thankfully.

My current theory on the process required for export is:

  # Convert bone vector to euler
  # Convert euler to matrix
  # Multiply euler by inverse parent matrix, write euler
  # Multiply matrix by parent's equivalents
  # Subtract parent head from bone head
  # Multiply location by inverse matrix, write location

And for import:

  # Convert euler to matrix
  # Convert location to matrix
  # Combine matrices
  # Head location = location * parent matrix
  # Tail rotation = location + ([0,0,1] * parent matrix)

Original issue reported on code.google.com by cont...@steamreview.org on 13 Aug 2010 at 12:49

GoogleCodeExporter commented 8 years ago

Original comment by cont...@steamreview.org on 25 Sep 2010 at 8:30