示例#1
0
def load(asfFilename, amcFilename, ignore=False):
    """ Loads an ASF/AMC file pair and creates an Animated Armature in
    Blender.

    asfFilename is the ASF file to load

    amcFilename is the AMC file to load

    ignore is a boolean specifying whether to ignore outer joints or not.
    """
    global asf, amc, ignoreOuterJoints
    try:
        asf = ASF()
        amc = AMC(asf)
        ignoreOuterJoints = ignore

        print 'importing asf/amc...'
        t1= Blender.sys.time()
        asf.parse(asfFilename)
        amc.parse(amcFilename)
        asf = amc.asf
        asf.calc_matrices()
        arm = make_armature(asf.name)
        arm.addProperty('num_frames',len(amc.frames),'INT')

        apply_animation(arm, amc)

        print 'done in %.4fs' % (Blender.sys.time()-t1)
        return arm.name
    except:
        raise Exception('Fileexcept')
示例#2
0
def stitch(asfFilename, firstAmc, stitchFilenames, ignore=False, transitionTime=120):
    """
    Creates a stitched motion from several amc files.

    asfFilename is the ASF filename for the skeleton used for all the
    motions.

    firstAmc is the AMC filename for the first motion

    stitchFilenames is a list of filenames for the rest of the motions.

    ignore is a boolean specifying whether to ignore outer joints or not.

    transitionTime is an integer specifying how many frames to use for
    interpolation.
    """
    global asf, amc, ignoreOuterJoints
    print 'importing and stitching asf/amc...'
    t1 = Blender.sys.time()
    
    try:
        asf = ASF()
        asf.parse(asfFilename)
        ignoreOuterJoints = ignore

        amc = AMC(asf)
        amc.parse(firstAmc)
        newasf = amc.asf
        newasf.calc_matrices()

        arm = make_armature(newasf.name)
        apply_animation(arm, amc)

        posOffset = Vector(0.,0.,0.)
        rotOffset = Vector(0.,0.,0.)

        prevamc = amc
        for amcFilename in stitchFilenames:
            amc = AMC(asf)
            amc.parse(amcFilename)
    
            newPosOffset = calcOffsetVec(prevamc, amc)
    
            posOffset += newPosOffset
    
            apply_animation(arm, amc, prevAMC=prevamc, frameOffset=transitionTime, posOffset=posOffset)
            prevamc = amc

        print 'done in %.4fs' % (Blender.sys.time()-t1)
        return arm.name
    except:
        raise Exception('Fileexcept')