示例#1
0
def import_lbf(path):
    editmode = Blender.Window.EditMode()
    if editmode: Blender.Window.EditMode(0)

    Blender.Window.WaitCursor(1)
    lbf_top = lbf.parseLBF(path)
    
    skelObj = None
    animNode = lbf_top.find( 'ANIM_SECTION' )
    if animNode:
        skelObj = _import_anim_section(animNode)

    obNode = lbf_top.find( 'OBJECT_SECTION' )
    if obNode:
        _import_obj_section( obNode, skelObj )
    
    Blender.Window.WaitCursor(0)
    
    if editmode: Blender.Window.EditMode(1)
    Blender.Window.RedrawAll()
示例#2
0
def import_lbf(path):
    editmode = Blender.Window.EditMode()
    if editmode: Blender.Window.EditMode(0)

    Blender.Window.WaitCursor(1)
    lbf_top = lbf.parseLBF(path)

    skelObj = None
    animNode = lbf_top.find('ANIM_SECTION')
    if animNode:
        skelObj = _import_anim_section(animNode)

    obNode = lbf_top.find('OBJECT_SECTION')
    if obNode:
        _import_obj_section(obNode, skelObj)

    Blender.Window.WaitCursor(0)

    if editmode: Blender.Window.EditMode(1)
    Blender.Window.RedrawAll()
示例#3
0
文件: lbf.py 项目: 1165048017/moged
def _main():
    lbffile = ''
    mode = 'list'
    outfile = ''

    try:
        opts, args = getopt.getopt(
            sys.argv[1:], "f:o:",
            ["file=", "out=", "ls", "copy", "clear-animations"])
        for opt, val in opts:
            if opt in ('-f', '--file'):
                lbffile = val
            elif opt in ('-o', '--out'):
                outfile = val
            elif opt == '--ls':
                mode = 'list'
            elif opt == '--copy':
                mode = 'copy'
            elif opt == '--clear-animations':
                mode = 'clear_anim'

    except getopt.GetoptError:
        _usage()
        sys.exit(1)

    if not os.path.exists(lbffile):
        print lbffile, "does not exist"
        sys.exit(2)

    if mode == 'list':
        try:
            print "Loading", lbffile
            lbftop = lbf.parseLBF(lbffile)
            print "LBF File Version:", str(lbftop.major_version) + "." + str(
                lbftop.minor_version)
            lbf.list_neighbors(lbftop.first_node)
        except lbf.LBFError as err:
            print "Error occurred:\n", err

    elif mode == 'copy':
        if lbffile == outfile:
            print "Cannot copy to same file"
            sys.exit(3)

        try:
            print "Copying %s to %s" % (lbffile, outfile)
            inlbf = lbf.parseLBF(lbffile)
            lbf.writeLBF(inlbf, outfile)
        except lbf.LBFError as err:
            print "Error occurred\n", err

    elif mode == 'clear_anim':
        if len(outfile) == 0:
            outfile = lbffile

        try:
            print "Loading", lbffile
            lbftop = lbf.parseLBF(lbffile)
            print "LBF File Version:", str(lbftop.major_version) + "." + str(
                lbftop.minor_version)

            animSection = lbftop.find('ANIM_SECTION')
            if animSection:
                animNode = animSection.find('ANIMATION')
                if animNode:
                    animCount = 0
                    while animNode:
                        animCount += 1
                        animSection.remove(animNode)
                        animNode = animSection.find('ANIMATION')
                    print "Clearing %s animations..." % (animCount)
                    print "Writing to %s " % (outfile)
                    lbf.writeLBF(lbftop, outfile)
                else:
                    print "No animations found."
            else:
                print "No animation section found."
        except lbf.LBFError as err:
            print "Error occurred\n", err
    return
示例#4
0
文件: lbf.py 项目: lpanian/moged
def _main():
    lbffile = ""
    mode = "list"
    outfile = ""

    try:
        opts, args = getopt.getopt(sys.argv[1:], "f:o:", ["file=", "out=", "ls", "copy", "clear-animations"])
        for opt, val in opts:
            if opt in ("-f", "--file"):
                lbffile = val
            elif opt in ("-o", "--out"):
                outfile = val
            elif opt == "--ls":
                mode = "list"
            elif opt == "--copy":
                mode = "copy"
            elif opt == "--clear-animations":
                mode = "clear_anim"

    except getopt.GetoptError:
        _usage()
        sys.exit(1)

    if not os.path.exists(lbffile):
        print lbffile, "does not exist"
        sys.exit(2)

    if mode == "list":
        try:
            print "Loading", lbffile
            lbftop = lbf.parseLBF(lbffile)
            print "LBF File Version:", str(lbftop.major_version) + "." + str(lbftop.minor_version)
            lbf.list_neighbors(lbftop.first_node)
        except lbf.LBFError as err:
            print "Error occurred:\n", err

    elif mode == "copy":
        if lbffile == outfile:
            print "Cannot copy to same file"
            sys.exit(3)

        try:
            print "Copying %s to %s" % (lbffile, outfile)
            inlbf = lbf.parseLBF(lbffile)
            lbf.writeLBF(inlbf, outfile)
        except lbf.LBFError as err:
            print "Error occurred\n", err

    elif mode == "clear_anim":
        if len(outfile) == 0:
            outfile = lbffile

        try:
            print "Loading", lbffile
            lbftop = lbf.parseLBF(lbffile)
            print "LBF File Version:", str(lbftop.major_version) + "." + str(lbftop.minor_version)

            animSection = lbftop.find("ANIM_SECTION")
            if animSection:
                animNode = animSection.find("ANIMATION")
                if animNode:
                    animCount = 0
                    while animNode:
                        animCount += 1
                        animSection.remove(animNode)
                        animNode = animSection.find("ANIMATION")
                    print "Clearing %s animations..." % (animCount)
                    print "Writing to %s " % (outfile)
                    lbf.writeLBF(lbftop, outfile)
                else:
                    print "No animations found."
            else:
                print "No animation section found."
        except lbf.LBFError as err:
            print "Error occurred\n", err
    return