def writeLibraryAnimations(fp, human, skel, animations, config):
    if skel is None:
        return

    # Use pose matrices, not skinning matrices
    for anim in animations:
        anim.resetBaked()

    joined_anim = animations[0]
    for anim in animations[1:]:
        print 'join anims'
        joined_anim = animation.joinAnimations(joined_anim, anim)

    fp.write('\n  <library_animations>\n')
    writeAnimation(fp, skel, joined_anim, config)
    fp.write('  </library_animations>\n')

    # Write animation clips (not supported by all importers)
    fp.write('\n  <library_animation_clips>\n')
    timeOffset = 0.0
    for anim in animations:
        fp.write('    <animation_clip id="AnimationClip_%s" name="%s" start="%.3f" end="%.3f">\n' % (anim.name, anim.name, timeOffset, timeOffset+anim.getPlaytime()))
        for bone in skel.getBones():
            aname = "Anim_%s_%s" % (joined_anim.name, goodBoneName(bone.name))
            fp.write('      <instance_animation url="#%s_pose_matrix"/>\n' % aname)
        fp.write('    </animation_clip>\n')
        # TODO it's also possible to export animations to separate files:
        #    <animation_clip="name" name="name">
        #      <instance_animation url="file://animation_file.dae#animationName"/>
        #    </animation_clip>
        timeOffset += anim.getPlaytime()
    fp.write('\n  </library_animation_clips>\n')
Ejemplo n.º 2
0
def writeLibraryAnimations(fp, human, skel, animations, config):
    if skel is None:
        return

    # Use pose matrices, not skinning matrices
    for anim in animations:
        anim.resetBaked()

    joined_anim = animations[0]
    for anim in animations[1:]:
        print('join anims')
        joined_anim = animation.joinAnimations(joined_anim, anim)

    fp.write('\n  <library_animations>\n')
    writeAnimation(fp, skel, joined_anim, config)
    fp.write('  </library_animations>\n')

    # Write animation clips (not supported by all importers)
    fp.write('\n  <library_animation_clips>\n')
    timeOffset = 0.0
    for anim in animations:
        fp.write('    <animation_clip id="AnimationClip_%s" name="%s" start="%.3f" end="%.3f">\n' % (anim.name, anim.name, timeOffset, timeOffset+anim.getPlaytime()))
        for bone in skel.getBones():
            aname = "Anim_%s_%s" % (joined_anim.name, goodBoneName(bone.name))
            fp.write('      <instance_animation url="#%s_pose_matrix"/>\n' % aname)
        fp.write('    </animation_clip>\n')
        # TODO it's also possible to export animations to separate files:
        #    <animation_clip="name" name="name">
        #      <instance_animation url="file://animation_file.dae#animationName"/>
        #    </animation_clip>
        timeOffset += anim.getPlaytime()
    fp.write('\n  </library_animation_clips>\n')