Exporting skeletal animations

(dcosborn) #1

I’m writing a skeletal animation exporter. I’ve made a simple cube attached to a single bone which rotates around the Z axis over 3 keyframes. When I print out the keyframe information, it doesn’t seem right at all. I’m getting quaternion transformation values of -1.5828e-23 and such. I only have 3 frames at 0, 24, and 48, each with simple orthogonal transforms. I’m using Blender 2.4 alpha-2, but I’ve also tried with Blender 2.37.

Here’s the Blender file: http://habitualhiatus.com/extern/box.blend
Here’s the script:

import Blender

for obj in Blender.Object.GetSelected():
	if type(obj.getData()) is Blender.Types.ArmatureType:
		for action in Blender.Armature.NLA.GetActions().itervalues():
			for channel, ipo in action.getAllChannelIpos().items():
				for curve in ipo.getCurves():
					for bez in curve.getPoints():
						print bez.pt

I know the values are QuatX, QuatY, QuatZ, and QuatW, so I’m assuming the Blender quaternions work the same way as your typical quaternion. So I’m expecting values in the range -1.0 to 1.0.

(osxrules) #2

-1.5828e-23 is in the range -1 to 1.

It is -0.000000000000000000000015828 or something i.e. practically zero. All you need to do is clip the decimal places.

(dcosborn) #3

Ah of course you’re right. But what I mean is all of the values are either 0.0 or practically zero. Since the transforms are all orthogonal, there should be values like 1.0 (180 degrees) and 0.7071 (90 degrees). Actually, all the IPO points are set to either -1.0, 0.0, and 1.0 in Blender. So I shouldn’t be getting any other values than those.

(osxrules) #4

Your script worked OK for me. I just set up a general armature and keyframed one of the bones over 3 frames (1,21,41) in various positions. The result I get is:

[1.0, 0.0]
[21.0, -0.049878578633069992]
[41.0, -0.062454711645841599]
[1.0, 0.0]
[21.0, -0.031650085002183914]
[41.0, -0.03962993249297142]
[1.0, 0.0]
[21.0, 0.63942581415176392]
[41.0, 0.80065077543258667]
[1.0, 1.0]
[21.0, 0.76658010482788086]
[41.0, -0.59454792737960815]

They correspond to QuatW,X,Y,Z

I’m using Blender 2.4a2 also.

(dcosborn) #5

Ok thanks for bearing with me. Its reassuring to hear that its working for you. I’ll try rebuilding the cube and see if I can get some more reasonable values.