Hey there,
I am currently writing a blender exporter, however, i have come across a stumbling block.
I am a bit puzzled about the armature and bones. The model format i am exporting them to seems to call them “nodes”, and they just seem to be linked together (no head or tail, just one location + quat)
However, I’ve managed to export them(the structure anyway), but trying to export the animation is another thing altogether.
Currently, the part of my script that exports 1 big sequence looks like(excuse the code, i am not very experienced with python) :
def AddSequences(shape):
readingFrames = 1
sqf = SeqFlag()
scene = Blender.Scene.GetCurrent() # Only export current scene
sq = ShapeSequence()
sq.name = "ambient"
#sq.flags = sqf.Cyclic # Add more flags.
sq.flags = 0
sq.fps = 1.0
sq.sFrame = scene.startFrame()-1
sq.eFrame = scene.endFrame()-1
for frameCount in range(scene.startFrame(),scene.endFrame()):
scene.currentFrame(frameCount)
bcount = 0
for bone in shape.Bones:
bBone = findBlenderBone(bone.name)
nt = NodeTranslation()
nt.bId = bcount
nt.frame = frameCount-1 # Frame...
nt.pos = bBone.getHead()
nt.quat = bBone.getQuat()
sq.translations.append(nt)
bcount += 1
scene.update()
# Add our sequence
shape.Sequences.append(sq)
I assume my code does the following :
- Change the frame
- Write the position and quat of all the bones
- Go to 1 till we have no more frames left
However, looking at the file i generated, it all goes horribly wrong. The starting position of the first bone is written ok, but subsequent bones seem to have no location. And even worse, all the bones seem to have the same quat(1, 0, 0, 0), even though i made some little animation (the bones rotate)
Can anyone tell me where i am going wrong?
Thanks