Import animation (posebone quat and loc using head and tail coords)

(puh) #1

Hello!

I’m trying to enhance smd importer by JMD (http://blenderartists.org/forum/showthread.php?t=103724) so that it could load animation.
Right now i have all frames loaded as posebones head and tail positions:
i added lines to be sure they are ok:
http://img35.picoodle.com/img/img35/9/10/4/t_blenderimpom_f690a3f.gif
How can i transpose those positions to insertKey ?
Function setPose was removed from API though in that case it was perfect solution i think.

Here is my function:


   def createActions(self):
       print 'Creating Action'

       # getting existing armature
       armobj = Object.Get('imported_armature')
       armdata = armobj.getData()
       pose = armobj.getPose()

       newaction = Armature.NLA.NewAction('imported_action')
       newaction.setActive(armobj)
       for bone in self.bones:
            rest_bone = armdata.bones[bone.name]
            bone_rest_matrix = rest_bone.matrix['ARMATURESPACE'].rotationPart()

            bone_rest_matrix_inv= Matrix(bone_rest_matrix)
            bone_rest_matrix_inv.invert()

            bone_rest_matrix_inv.resize4x4()
            bone_rest_matrix.resize4x4()

            pbone = pose.bones[bone.name]
            for frm in bone.frames:
                headVec = frm.phead
                tailVec = frm.ptail
                add_line(headVec, tailVec, bone.name + ":" + str(frm.number))
                matrix3 = matrix3.resize4x4() * bone_rest_matrix * bone_rest_matrix_inv
                pbone.quat = matrix3.toQuat()
                pbone.insertKey(armobj,frm.number,[Object.Pose.ROT])
                #pbone.loc = (bone_rest_matrix*matrix3).translationPart().resize3D()
                #pbone.insertKey(armobj,frm.number,[Object.Pose.LOC])


Thank you for any help.:o

0 Likes

(puh) #2

So noone could help with this?
here is whole script in case you want to look at:
http://karpena.googlepages.com/import_smd_animation.py

0 Likes