示例#1
0
def exportMhx(human, filename, options):    
    the.Config = export_config.exportConfig(human, True, options)
    (fpath, ext) = os.path.splitext(filename)

    if '24' in the.Config.mhxversion:
        mhx_24.exportMhx(human, filename, options)
   
    if '25' in the.Config.mhxversion:
        time1 = time.clock()
        fname = os.path.basename(fpath)
        the.Human = fname.capitalize().replace(' ','_')
        outfile = export_config.getOutFileFolder(filename, the.Config)        
        try:
            fp = open(outfile, 'w')
            print("Writing MHX 2.5x file",  outfile )
        except:
            print("Unable to open file for writing", outfile)
            fp = 0
        if fp:
            exportMhx_25(human, fp)
            fp.close()
            time2 = time.clock()
            print("Wrote MHX 2.5x file in %g s:" % (time2-time1), outfile)

    return        
示例#2
0
def exportMhx(human, filename, options):
    posemode.exitPoseMode()
    posemode.enterPoseMode()
    config = export_config.exportConfig(human, True, options)
    (fpath, ext) = os.path.splitext(filename)

    if '24' in config.mhxversion:
        mhx_24.exportMhx(human, filename, options, config)

    if '25' in config.mhxversion:
        time1 = time.clock()
        fname = os.path.basename(fpath)
        the.Human = fname.capitalize().replace(' ', '_')
        outfile = export_config.getOutFileFolder(filename, config)
        try:
            fp = open(outfile, 'w')
            log.message("Writing MHX 2.5x file %s", outfile)
        except:
            log.message("Unable to open file for writing %s", outfile)
            fp = 0
        if fp:
            #cProfile.runctx( 'exportMhx_25(human, config, fp)', globals(), locals())
            exportMhx_25(human, config, fp)
            fp.close()
            time2 = time.clock()
            log.message("Wrote MHX 2.5x file in %g s: %s", time2 - time1,
                        outfile)

    posemode.exitPoseMode()
    return
示例#3
0
def exportMhx(human, filename, options):  
    posemode.exitPoseMode()        
    posemode.enterPoseMode()
    config = export_config.exportConfig(human, True, options)
    (fpath, ext) = os.path.splitext(filename)

    if '24' in config.mhxversion:
        mhx_24.exportMhx(human, filename, options, config)
   
    if '25' in config.mhxversion:
        time1 = time.clock()
        fname = os.path.basename(fpath)
        the.Human = fname.capitalize().replace(' ','_')
        outfile = export_config.getOutFileFolder(filename, config)        
        try:
            fp = open(outfile, 'w')
            log.message("Writing MHX 2.5x file %s", outfile )
        except:
            log.message("Unable to open file for writing %s", outfile)
            fp = 0
        if fp:
            #cProfile.runctx( 'exportMhx_25(human, config, fp)', globals(), locals())
            exportMhx_25(human, config, fp)
            fp.close()
            time2 = time.clock()
            log.message("Wrote MHX 2.5x file in %g s: %s", time2-time1, outfile)

    posemode.exitPoseMode()        
    return        
def exportProxyObj(human, name, options):
    obj = human.meshData
    the.Config = export_config.exportConfig(human, True)
    the.Options = options
    the.Config.separatefolder = True
    print(options.items())
    (the.Stuff, stuffs) = mh2collada.setupStuff(name, obj, {}, [], the.Config)
    (scale, unit) = options["scale"]   
    #name = export_config.goodName(name)
    outfile = export_config.getOutFileFolder(name+".obj", the.Config)   
    (path, ext) = os.path.splitext(outfile)

    filename = "%s_clothed.obj" % path
    fp = open(filename, 'w')
    fp.write(
"# MakeHuman exported OBJ with clothes\n" +
"# www.makehuman.org\n\n" +
"mtllib %s_clothed.obj.mtl\n" % os.path.basename(path))
    for stuff in stuffs:
        writeGeometry(obj, fp, stuff, scale)
    fp.close()
    
    filename = "%s_clothed.obj.mtl" % path
    fp = open(filename, 'w')
    fp.write(
'# MakeHuman exported MTL with clothes\n' +
'# www.makehuman.org\n\n')
    for stuff in stuffs:
        writeMaterial(fp, stuff, human)
    fp.close()
    return
示例#5
0
def exportProxyObj(human, name, options):
    obj = human.meshData
    cfg = export_config.exportConfig(human, True)
    cfg.separatefolder = True

    stuffs = object_collection.setupObjects(os.path.splitext(name)[0],
                                            human,
                                            helpers=options["helpers"],
                                            hidden=options["hidden"],
                                            eyebrows=options["eyebrows"],
                                            lashes=options["lashes"],
                                            subdivide=options["subdivide"])

    (scale, unit) = options["scale"]
    #name = export_config.goodName(name)
    outfile = export_config.getOutFileFolder(name, cfg)
    (path, ext) = os.path.splitext(outfile)

    filename = "%s_clothed.obj" % path
    fp = open(filename, 'w')
    fp.write("# MakeHuman exported OBJ with clothes\n" +
             "# www.makehuman.org\n\n" +
             "mtllib %s_clothed.obj.mtl\n" % os.path.basename(path))
    for stuff in stuffs:
        writeGeometry(obj, fp, stuff, scale)
    fp.close()

    filename = "%s_clothed.obj.mtl" % path
    fp = open(filename, 'w')
    fp.write('# MakeHuman exported MTL with clothes\n' +
             '# www.makehuman.org\n\n')
    for stuff in stuffs:
        writeMaterial(fp, stuff, human, cfg)
    fp.close()
    return
示例#6
0
def exportFbx(human, filepath, options):
    posemode.exitPoseMode()
    posemode.enterPoseMode()

    the.Human = human
    the.Config = export_config.exportConfig(human, True, [])
    the.Config.separatefolder = True
    outfile = export_config.getOutFileFolder(filepath, the.Config)
    (outpath, ext) = os.path.splitext(outfile)

    log.message("Write FBX file %s" % outfile)

    rawTargets = []
    if options["expressions"]:
        shapeList = read_expression.readExpressionUnits(human, 0, 1)
        rawTargets += shapeList

    if options["customshapes"]:
        the.Config.customshapes = True
        mhx_custom.listCustomFiles(the.Config)

        log.message("Custom shapes:")
        for path, name in the.Config.customShapeFiles:
            log.message("    %s", path)
            shape = mhx_custom.readCustomTarget(path)
            target = (name, shape)
            rawTargets.append(target)

    rigfile = "data/rigs/%s.rig" % options["fbxrig"]
    stuffs = object_collection.setupObjects(
        os.path.splitext(outfile)[0],
        human,
        rigfile,
        rawTargets=rawTargets,
        helpers=options["helpers"],
        hidden=options["hidden"],
        eyebrows=options["eyebrows"],
        lashes=options["lashes"],
    )

    (scale, unit) = options["scale"]

    bpy.initialize()
    name = os.path.splitext(os.path.basename(filepath))[0]
    boneInfo = stuffs[0].boneInfo
    rig = bpy.addRig(name, boneInfo)
    for stuff in stuffs:
        ob = bpy.addMesh(stuff.name, stuff, True)
        ob.parent = rig

    # name = os.path.splitext(os.path.basename(filepath))[0]
    # bpy.addMesh(name, human.meshData, False)

    filename = "%s.fbx" % outpath
    io_mh_fbx.fbx_export.exportFbxFile(bpy.context, filename)
    posemode.exitPoseMode()
    return
示例#7
0
def exportFbx(human, filepath, options):
    posemode.exitPoseMode()        
    posemode.enterPoseMode()
    
    the.Human = human        
    the.Config = export_config.exportConfig(human, True, [])
    the.Config.separatefolder = True
    outfile = export_config.getOutFileFolder(filepath, the.Config)        
    (outpath, ext) = os.path.splitext(outfile)

    log.message("Write FBX file %s" % outfile)

    rawTargets = []
    if options["expressions"]:
        shapeList = read_expression.readExpressionUnits(human, 0, 1)
        rawTargets += shapeList

    if options["customshapes"]:
        the.Config.customshapes = True
        mhx_custom.listCustomFiles(the.Config)                            

        log.message("Custom shapes:")    
        for path,name in the.Config.customShapeFiles:
            log.message("    %s", path)
            shape = mhx_custom.readCustomTarget(path)
            target = (name,shape)
            rawTargets.append(target)

    rigfile = "data/rigs/%s.rig" % options["fbxrig"]
    stuffs = object_collection.setupObjects(
        os.path.splitext(outfile)[0], 
        human, 
        rigfile, 
        rawTargets=rawTargets,
        helpers=options["helpers"], 
        hidden=options["hidden"], 
        eyebrows=options["eyebrows"], 
        lashes=options["lashes"])

    (scale, unit) = options["scale"]   

    bpy.initialize()
    name = os.path.splitext(os.path.basename(filepath))[0]
    boneInfo = stuffs[0].boneInfo
    rig = bpy.addRig(name, boneInfo)
    for stuff in stuffs:
        ob = bpy.addMesh(stuff.name, stuff, True)
        ob.parent = rig
        
    #name = os.path.splitext(os.path.basename(filepath))[0]
    #bpy.addMesh(name, human.meshData, False)
    
    filename = "%s.fbx" % outpath
    io_mh_fbx.fbx_export.exportFbxFile(bpy.context, filename)
    posemode.exitPoseMode()        
    return
示例#8
0
def exportCollada(human, filename, options):
    time1 = time.clock()
    the.Config = export_config.exportConfig(human, True, [])
    the.Config.separatefolder = True
    the.Rotate90X = options["rotate90X"]
    the.Rotate90Z = options["rotate90Z"]
    the.Options = options
    outfile = export_config.getOutFileFolder(filename, the.Config)        
    try:
        fp = open(outfile, 'w')
        log.message("Writing Collada file %s" % outfile)
    except:
        log.error("Unable to open file for writing %s" % outfile)
    (name,ext) = os.path.splitext(os.path.basename(outfile))
    exportDae(human, name, fp)
    fp.close()
    time2 = time.clock()
    log.message("Wrote Collada file in %g s: %s" % (time2-time1, outfile))
    return
示例#9
0
def exportCollada(human, filename, options):
    time1 = time.clock()
    the.Config = export_config.exportConfig(human, True, [])
    the.Config.separatefolder = True
    the.Rotate90X = options["rotate90X"]
    the.Rotate90Z = options["rotate90Z"]
    the.Options = options
    outfile = export_config.getOutFileFolder(filename, the.Config)
    try:
        fp = open(outfile, 'w')
        log.message("Writing Collada file %s" % outfile)
    except:
        log.error("Unable to open file for writing %s" % outfile)
    (name, ext) = os.path.splitext(os.path.basename(outfile))
    exportDae(human, name, fp)
    fp.close()
    time2 = time.clock()
    log.message("Wrote Collada file in %g s: %s" % (time2 - time1, outfile))
    return
示例#10
0
def exportCollada(human, filename, options):
    time1 = time.clock()
    the.Config = export_config.exportConfig(human, True, [])
    the.Config.separatefolder = True
    the.Rotate90X = options["rotate90X"]
    the.Rotate90Z = options["rotate90Z"]
    the.Config.pngTexture = options["pngTexture"]
    the.Options = options
    outfile = export_config.getOutFileFolder(filename+".dae", the.Config)        
    try:
        fp = open(outfile, 'w')
        print("Writing Collada file", outfile)
    except:
        print("Unable to open file for writing", outfile)
    (name,ext) = os.path.splitext(os.path.basename(outfile))
    exportDae(human, name, fp)
    fp.close()
    time2 = time.clock()
    print("Wrote Collada file in %g s:" % (time2-time1), outfile)
    return
示例#11
0
def exportProxyObj(human, name, options):
    obj = human.meshData
    cfg = export_config.exportConfig(human, True)
    cfg.separatefolder = True

    stuffs = object_collection.setupObjects(os.path.splitext(name)[0], human,
        helpers=options["helpers"], 
        hidden=options["hidden"], 
        eyebrows=options["eyebrows"], 
        lashes=options["lashes"],
        subdivide=options["subdivide"])
    
    (scale, unit) = options["scale"]   
    #name = export_config.goodName(name)
    outfile = export_config.getOutFileFolder(name, cfg)   
    (path, ext) = os.path.splitext(outfile)

    filename = "%s_clothed.obj" % path
    fp = open(filename, 'w')
    fp.write(
"# MakeHuman exported OBJ with clothes\n" +
"# www.makehuman.org\n\n" +
"mtllib %s_clothed.obj.mtl\n" % os.path.basename(path))
    for stuff in stuffs:
        writeGeometry(obj, fp, stuff, scale)
    fp.close()
    
    filename = "%s_clothed.obj.mtl" % path
    fp = open(filename, 'w')
    fp.write(
'# MakeHuman exported MTL with clothes\n' +
'# www.makehuman.org\n\n')
    for stuff in stuffs:
        writeMaterial(fp, stuff, human, cfg)
    fp.close()
    return