Exemplo n.º 1
0
def writeRigPose(fp, name, bones):
    circles = []
    cubes = []
    for (bone, head, tail, roll, parent, options) in bones:
        r = getRadius('-circ', options)
        if r and not (r in circles):
            mhx_rig.setupCircle(fp, "RigCircle%02d" % r, 0.1*r)
            circles.append(r)
        r = getRadius('-box', options)
        if r and not (r in cubes):
            mhx_rig.setupCube(fp, "RigCube%02d" % r, 0.1*r, 0)
            cubes.append(r)

    fp.write("\nPose %s\n" % name)
    for (bone, head, tail, roll, parent, options) in bones:
        fp.write("  Posebone %s True \n" % bone)

        # IK constraint
        try:
            val = options['-ik']
        except:
            val = None
        if val:
            (subtar, chainlen, inf) = val
            fp.write(
"    Constraint IK IK True\n")
            if subtar:
                fp.write(
"      target Refer Object %s ;\n" % name +
"      subtarget '%s' ;\n" % subtar +
"      use_tail True ;\n" +
"      use_target True ;\n")
            else:
                fp.write(
"      use_tail False ;\n" +
"      use_target True ;\n")
            fp.write(
"      chain_count %s ;\n" % chainlen +
"      influence %s ;\n" % inf +
"    end Constraint\n")

        # Not connected
        try:
            options['-nc']
        except:
            fp.write(
"    lock_location Array 1 1 1 ;\n" +
"    lock_scale Array 1 1 1  ; \n")

        # Circle custom shape
        r = getRadius('-circ', options)
        if r:
            fp.write(
"    custom_shape Refer Object RigCircle%02d ; \n" % r)

        # Box custom shape
        r = getRadius('-box', options)
        if r:
            fp.write(
"    custom_shape Refer Object RigCube%02d ; \n" % r)

        fp.write("  end Posebone\n")
    fp.write("end Pose\n\n")
Exemplo n.º 2
0
def exportMhx_25(human, fp):
    gui3d.app.progress(0, text="Exporting MHX")

    fp.write(
"# MakeHuman exported MHX\n" +
"# www.makehuman.org\n" +
"MHX %d %d ;\n" % (MAJOR_VERSION, MINOR_VERSION) +
"#if Blender24\n" +
"  error 'This file can only be read with Blender 2.5' ;\n" +
"#endif\n")

    obj = human.meshData
    proxyData = {}
    scanProxies(obj, proxyData)
    mhx_rig.setupRig(obj, proxyData)
    
    if not the.Config.cage:
        fp.write(
    "#if toggle&T_Cage\n" +
    "  error 'This MHX file does not contain a cage. Unselect the Cage import option.' ;\n" +
    "#endif\n")

    fp.write(
"NoScale True ;\n" +
"Object CustomShapes EMPTY None\n" +
"  layers Array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1  ;\n" +
"end Object\n\n")

    fp.write("#if toggle&T_Armature\n")
    if the.Config.mhxrig in ['mhx', 'rigify', 'blenrig']:
        for fname in the.GizmoFiles:
            copyFile25(human, fname, fp, None, proxyData)    
        mhx_rig.setupCircles(fp)
    else:
        for (name, data) in the.CustomShapes.items():
            (typ, r) = data
            if typ == "-circ":
                mhx_rig.setupCircle(fp, name, 0.1*r)
            elif typ == "-box":
                mhx_rig.setupCube(fp, name, 0.1*r, (0,0,0))
            else:
                halt
        if the.Config.facepanel:
            mhx_rig.setupCube(fp, "MHCube025", 0.25, 0)
            mhx_rig.setupCube(fp, "MHCube05", 0.5, 0)
            copyFile25(human, "shared/mhx/templates/panel_gizmo25.mhx", fp, None, proxyData)    
            
    gui3d.app.progress(0.1, text="Exporting armature")
    copyFile25(human, "shared/mhx/templates/rig-armature25.mhx", fp, None, proxyData)    
    fp.write("#endif\n")

    gui3d.app.progress(0.15, text="Exporting materials")    
    fp.write("\nNoScale False ;\n\n")

    if human.uvsetFile:
        uvset = mh2proxy.readUvset(human.uvsetFile)
        proxyData["__uvset__"] = uvset
        writeMultiMaterials(uvset, human, fp)
    else:
        copyFile25(human, "shared/mhx/templates/materials25.mhx", fp, None, proxyData)    

    gui3d.app.progress(0.2, text="Exporting cage")
    if the.Config.cage:
        proxyCopy('Cage', human, proxyData, fp, 0.25, 0.3)

    gui3d.app.progress(0.25, text="Exporting main mesh")    
    if the.Config.mainmesh:
        fp.write("#if toggle&T_Mesh\n")
        copyFile25(human, "shared/mhx/templates/meshes25.mhx", fp, None, proxyData)    
        fp.write("#endif\n")

    proxyCopy('Proxy', human, proxyData, fp, 0.4, 0.45)
    proxyCopy('Clothes', human, proxyData, fp, 0.45, 0.6)

    copyFile25(human, "shared/mhx/templates/rig-poses25.mhx", fp, None, proxyData) 

    if the.Config.mhxrig == 'rigify':
        fp.write("Rigify %s ;\n" % the.Human)

    gui3d.app.progress(1.0)
    return