PiRSquared17 / yabee

Automatically exported from code.google.com/p/yabee
0 stars 0 forks source link

Allow bone scaling for armature animation #31

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Basically add/replace the following sections in egg_writer.py to export the 
bone scale instead of 1.0:

Change in class EGGAnimJoint(Group):
# FROM ----
   def get_full_egg_str(...):
       egg_str = ''
       if .... :
           for i in range(len(bone_data['r'])):
                egg_str += '%s      %s %s %s %s %s %s %s %s %s\n' % (
                                                    '  ' * level, 
                                                    STRF(1.0), 
                                                    STRF(1.0), 
                                                    STRF(1.0), 
                                                    STRF(bone_data['p'][i]), 
                                                    ...

# TO --------------
   def get_full_egg_str(...):
       egg_str = ''
       if .... :
           for i in range(len(bone_data['r'])):
                egg_str += '%s      %s %s %s %s %s %s %s %s %s\n' % (
                                                    '  ' * level, 
                                                    STRF(bone_data['i'][i]), 
                                                    STRF(bone_data['j'][i]), 
                                                    STRF(bone_data['k'][i]), 
                                                    STRF(bone_data['p'][i]), 

# ------------------------------------
add the following:
class AnimCollector():
    ....
    def collect_arm_anims(self, arm):
        ....
                if bone.parent:
                    matrix = bone.parent.matrix.inverted() * bone.matrix
                else:
                    matrix = arm.matrix_world * bone.matrix

                # ADDED CODE BEGINS HERE
                i, j, k = matrix.to_scale()
                anim_dict[bone.yabee_name]['i'].append(i)
                anim_dict[bone.yabee_name]['j'].append(j)
                anim_dict[bone.yabee_name]['k'].append(k)
                # ADDED CODE ENDS HERE
                p, r, h = matrix.to_euler()
                anim_dict[bone.yabee_name]['p'].append(p/pi*180)
                anim_dict[bone.yabee_name]['r'].append(r/pi*180)
                anim_dict[bone.yabee_name]['h'].append(h/pi*180)

Original issue reported on code.google.com by RealHiPh...@gmail.com on 21 Feb 2014 at 10:58

GoogleCodeExporter commented 9 years ago
Ok. Thanks!

Original comment by ruPand...@gmail.com on 7 May 2014 at 4:46