Пример #1
0
def doSaveTarget(context, filepath):    
    ob = context.object
    if not utils.isTarget(ob):
        raise NameError("%s is not a target")
    bpy.ops.object.mode_set(mode='OBJECT')
    ob.active_shape_key_index = ob["NTargets"]
    if not checkValid(ob):
        return
    saveAll = not ob["SelectedOnly"]
    skey = ob.active_shape_key    
    if skey.name[0:6] == "Target":
        skey.name = utils.nameFromPath(filepath)
    verts = evalVertLocations(ob)
    
    (fname,ext) = os.path.splitext(filepath)
    filepath = fname + ".target"
    fp = open(filepath, "w")  
    print("Saving target %s to %s" % (ob, filepath))
    for n,vco in verts.items():
        bv = ob.data.vertices[n]
        vec = vco - bv.co
        if vec.length > the.Epsilon and (saveAll or bv.select):
            fp.write("%d %.6f %.6f %.6f\n" % (n, vec[0], vec[2], -vec[1]))
    fp.close()    
    ob["FilePath"] = filepath
Пример #2
0
def fitTarget(context):
    ob = context.object
    settings = getSettings(ob)
    bpy.ops.object.mode_set(mode='OBJECT')
    scn = context.scene
    if not utils.isTarget(ob):
        return
    ob.active_shape_key_index = ob["NTargets"]
    if not checkValid(ob):
        return
    if not mh.proxy:
        path = ob["ProxyFile"]
        if path:
            print("Rereading %s" % path)
            mh.proxy = mh_utils.proxy.CProxy()
            mh.proxy.read(path)
        else:
            raise NameError("Object %s has no associated mhclo file. Cannot fit" % ob.name)
            return
    if ob.MhAffectOnly != 'All':
        first,last = settings.affectedVerts[ob.MhAffectOnly]
        mh.proxy.update(ob.active_shape_key.data, ob.active_shape_key.data, skipBefore=first, skipAfter=last)
    else:
        mh.proxy.update(ob.active_shape_key.data, ob.active_shape_key.data)
    return
Пример #3
0
def fitTarget(context):
    ob = context.object
    settings = getSettings(ob)
    bpy.ops.object.mode_set(mode='OBJECT')
    scn = context.scene
    if not utils.isTarget(ob):
        return
    ob.active_shape_key_index = ob["NTargets"]
    if not checkValid(ob):
        return
    if not mh.proxy:
        path = ob["ProxyFile"]
        if path:
            print("Rereading %s" % path)
            mh.proxy = mh_utils.proxy.CProxy()
            mh.proxy.read(path)
        else:
            raise NameError(
                "Object %s has no associated mhclo file. Cannot fit" % ob.name)
            return
    if ob.MhAffectOnly != 'All':
        first, last = settings.affectedVerts[ob.MhAffectOnly]
        mh.proxy.update(ob.active_shape_key.data,
                        ob.active_shape_key.data,
                        skipBefore=first,
                        skipAfter=last)
    else:
        mh.proxy.update(ob.active_shape_key.data, ob.active_shape_key.data)
    return
Пример #4
0
def symmetrizeTarget(context, left2right):
    utils.setupVertexPairs(context, False)
    ob = context.object
    scn = context.scene
    if not utils.isTarget(ob):
        return
    bpy.ops.object.mode_set(mode='OBJECT')
    verts = ob.active_shape_key.data
    bverts = ob.data.vertices
    for vn in the.Mid.keys():
        v = verts[vn]
        v.co[0] = 0
    for (lvn,rvn) in the.Left.items():
        lv = verts[lvn].co
        rv = verts[rvn].co
        if left2right:
            rv[0] = -lv[0]
            rv[1] = lv[1]
            rv[2] = lv[2]
            bverts[rvn].select = bverts[lvn].select
        else:
            lv[0] = -rv[0]
            lv[1] = rv[1]
            lv[2] = rv[2]
            bverts[lvn].select = bverts[rvn].select
    print("Target symmetrized")
    return
Пример #5
0
def discardTarget(context):
    ob = context.object
    if not utils.isTarget(ob):
        return
    bpy.ops.object.mode_set(mode='OBJECT')
    ob.active_shape_key_index = ob["NTargets"]
    bpy.ops.object.shape_key_remove()
    ob["NTargets"] -= 1
    ob.active_shape_key_index = ob["NTargets"]
    checkValid(ob)
    return
Пример #6
0
def symmetrizeTarget(context, left2right, mirror):
    pairing = CPairing().setup(context, False)
    ob = context.object
    scn = context.scene
    if not utils.isTarget(ob):
        return
    bpy.ops.object.mode_set(mode='OBJECT')
    verts = ob.active_shape_key.data

    for vn in pairing.mid.keys():
        v = verts[vn]
        v.co[0] = 0

    for (lvn, rvn) in pairing.left.items():
        lv = verts[lvn].co
        rv = verts[rvn].co
        if mirror:
            tv = rv.copy()
            verts[rvn].co = (-lv[0], lv[1], lv[2])
            verts[lvn].co = (-tv[0], tv[1], tv[2])
        elif left2right:
            rv[0] = -lv[0]
            rv[1] = lv[1]
            rv[2] = lv[2]
        else:
            lv[0] = -rv[0]
            lv[1] = rv[1]
            lv[2] = rv[2]

    bverts = ob.data.vertices
    selected = {}
    for v in bverts:
        selected[v.index] = v.select

    bpy.ops.object.mode_set(mode='EDIT')
    bpy.ops.mesh.select_all(action='DESELECT')
    bpy.ops.object.mode_set(mode='OBJECT')

    for vn in pairing.mid.keys():
        bverts[vn].select = selected[vn]

    for (lvn, rvn) in pairing.left.items():
        if mirror:
            bverts[lvn].select = selected[rvn]
            bverts[rvn].select = selected[lvn]
        elif left2right:
            bverts[lvn].select = selected[lvn]
            bverts[rvn].select = selected[lvn]
        else:
            bverts[lvn].select = selected[rvn]
            bverts[rvn].select = selected[rvn]

    print("Target symmetrized")
    return
Пример #7
0
def discardTarget(context):
    ob = context.object
    if not utils.isTarget(ob):
        return
    bpy.ops.object.mode_set(mode='OBJECT')
    ob.active_shape_key_index = ob["NTargets"]
    bpy.ops.object.shape_key_remove()
    ob["NTargets"] -= 1
    ob.active_shape_key_index = ob["NTargets"]
    checkValid(ob)
    return
Пример #8
0
def symmetrizeTarget(context, left2right, mirror):
    pairing = CPairing().setup(context, False)
    ob = context.object
    scn = context.scene
    if not utils.isTarget(ob):
        return
    bpy.ops.object.mode_set(mode='OBJECT')
    verts = ob.active_shape_key.data
    
    for vn in pairing.mid.keys():
        v = verts[vn]
        v.co[0] = 0
        
    for (lvn,rvn) in pairing.left.items():
        lv = verts[lvn].co
        rv = verts[rvn].co
        if mirror:
            tv = rv.copy()
            verts[rvn].co = (-lv[0], lv[1], lv[2])
            verts[lvn].co = (-tv[0], tv[1], tv[2])
        elif left2right:
            rv[0] = -lv[0]
            rv[1] = lv[1]
            rv[2] = lv[2]
        else:
            lv[0] = -rv[0]
            lv[1] = rv[1]
            lv[2] = rv[2]

    bverts = ob.data.vertices    
    selected = {}
    for v in bverts:
        selected[v.index] = v.select

    bpy.ops.object.mode_set(mode='EDIT')
    bpy.ops.mesh.select_all(action='DESELECT')
    bpy.ops.object.mode_set(mode='OBJECT')
        
    for vn in pairing.mid.keys():
        bverts[vn].select = selected[vn]

    for (lvn,rvn) in pairing.left.items():
        if mirror:
            bverts[lvn].select = selected[rvn]
            bverts[rvn].select = selected[lvn]
        elif left2right:
            bverts[lvn].select = selected[lvn]
            bverts[rvn].select = selected[lvn]
        else:
            bverts[lvn].select = selected[rvn]
            bverts[rvn].select = selected[rvn]

    print("Target symmetrized")
    return
Пример #9
0
def fitTarget(context):
    ob = context.object
    bpy.ops.object.mode_set(mode='OBJECT')
    scn = context.scene
    if not utils.isTarget(ob):
        return
    ob.active_shape_key_index = ob["NTargets"]
    if not checkValid(ob):
        return
    if not the.Proxy:
        path = ob["ProxyFile"]
        if path:
            print("Rereading %s" % path)
            the.Proxy = proxy.CProxy()
            the.Proxy.read(path)
        else:
            raise NameError("Object %s has no associated mhclo file. Cannot fit" % ob.name)
            return
    #print(the.Proxy)
    the.Proxy.update(ob.active_shape_key.data, ob.active_shape_key.data)
    return
Пример #10
0
def doSaveTarget(context, filepath):    
    ob = context.object
    settings = getSettings(ob)
    if not utils.isTarget(ob):
        raise NameError("%s is not a target")
    bpy.ops.object.mode_set(mode='OBJECT')
    ob.active_shape_key_index = ob["NTargets"]
    if not checkValid(ob):
        return
    saveAll = not ob.SelectedOnly
    skey = ob.active_shape_key    
    if skey.name[0:6] == "Target":
        skey.name = utils.nameFromPath(filepath)
    verts = evalVertLocations(ob)
    
    (fname,ext) = os.path.splitext(filepath)
    filepath = fname + ".target"
    print("Saving target %s to %s" % (ob, filepath))
    if False and ob.MhMeshVertsDeleted and ob.MhAffectOnly != 'All':
        first,last = settings.affectedVerts[ob.MhAffectOnly]
        before,after = readLines(filepath, first,last)
        fp = open(filepath, "w", encoding="utf-8", newline="\n")  
        for line in before:
            fp.write(line)
        if ob.MhMeshVertsDeleted:
            offset = settings.offsetVerts[ob.MhAffectOnly]
        else:
            offset = 0
        saveVerts(fp, ob, verts, saveAll, first, last, offset)
        for (vn, string) in after:
            fp.write("%d %s" % (vn, string))
    else:
        fp = open(filepath, "w", encoding="utf-8", newline="\n")  
        saveVerts(fp, ob, verts, saveAll, 0, len(verts), 0)
    fp.close()    
    ob["FilePath"] = filepath
Пример #11
0
def doSaveTarget(context, filepath):
    ob = context.object
    settings = getSettings(ob)
    if not utils.isTarget(ob):
        raise NameError("%s is not a target")
    bpy.ops.object.mode_set(mode='OBJECT')
    ob.active_shape_key_index = ob["NTargets"]
    if not checkValid(ob):
        return
    saveAll = not ob.SelectedOnly
    skey = ob.active_shape_key
    if skey.name[0:6] == "Target":
        skey.name = utils.nameFromPath(filepath)
    verts = evalVertLocations(ob)

    (fname, ext) = os.path.splitext(filepath)
    filepath = fname + ".target"
    print("Saving target %s to %s" % (ob, filepath))
    if False and ob.MhMeshVertsDeleted and ob.MhAffectOnly != 'All':
        first, last = settings.affectedVerts[ob.MhAffectOnly]
        before, after = readLines(filepath, first, last)
        fp = open(filepath, "w", encoding="utf-8", newline="\n")
        for line in before:
            fp.write(line)
        if ob.MhMeshVertsDeleted:
            offset = settings.offsetVerts[ob.MhAffectOnly]
        else:
            offset = 0
        saveVerts(fp, ob, verts, saveAll, first, last, offset)
        for (vn, string) in after:
            fp.write("%d %s" % (vn, string))
    else:
        fp = open(filepath, "w", encoding="utf-8", newline="\n")
        saveVerts(fp, ob, verts, saveAll, 0, len(verts), 0)
    fp.close()
    ob["FilePath"] = filepath
Пример #12
0
    def draw(self, context):
        layout = self.layout
        ob = context.object
        if ob:
            rig = ob.parent
        else:
            rig = None
        scn = context.scene
        if not utils.drawConfirm(layout, scn):
            return

        if Thomas:
            layout.label("Pruning")
            row = layout.row()
            row.prop(ob, "MhPruneEnabled")
            row.prop(ob, "MhPruneWholeDir")
            row.prop(ob, "MhPruneRecursively")
            layout.operator("mh.prune_target_file")

        if not utils.isBaseOrTarget(ob):
            layout.operator("mh.import_base_obj")
            layout.operator("mh.import_base_mhclo")
            layout.operator("mh.make_base_obj")

        elif utils.isBase(ob):
            layout.label("Load Target")
            layout.operator("mh.new_target")
            layout.operator("mh.load_target")            
            layout.operator("mh.load_target_from_mesh")                        

        elif utils.isTarget(ob):
            if not ob.data.shape_keys:
                layout.label("Warning: Internal inconsistency")
                layout.operator("mh.fix_inconsistency")
                return
            layout.separator()
            box = layout.box()
            n = 0
            for skey in ob.data.shape_keys.key_blocks:
                if n == 0:
                    n += 1
                    continue
                row = box.row()
                if n == ob.active_shape_key_index:
                    icon='LAMP'
                else:
                    icon='X'
                row.label("", icon=icon)
                row.prop(skey, "value", text=skey.name)
                n += 1

            layout.label("Load Target")
            layout.operator("mh.new_target", text="New Secondary Target")
            layout.operator("mh.load_target", text="Load Secondary From File")            
            layout.operator("mh.load_target_from_mesh", text="Load Secondary From Mesh")    
            ext = os.path.splitext(ob.MhFilePath)[1]
            if ext == ".mhclo":
                layout.operator("mh.fit_target")

            layout.label("Discard And Apply Target")
            layout.operator("mh.discard_target")
            layout.operator("mh.discard_all_targets")
            layout.operator("mh.apply_targets")

            layout.label("Symmetry")
            row = layout.row()            
            row.operator("mh.symmetrize_target", text="Left->Right").action = "Left"
            row.operator("mh.symmetrize_target", text="Right->Left").action = "Right"
            if Thomas:
                row.operator("mh.symmetrize_target", text="Mirror").action = "Mirror"

            layout.label("Save Target")            
            layout.prop(ob, "SelectedOnly")
            layout.prop(ob, "MhZeroOtherTargets")
            if ob["FilePath"]:
                layout.operator("mh.save_target")           
            layout.operator("mh.saveas_target")       

            if not ob.MhDeleteHelpers:
                layout.label("Skirt Editing")
                layout.operator("mh.snap_waist")
                layout.operator("mh.straighten_skirt")            
                if ob.MhIrrelevantDeleted:
                    layout.separator()
                    layout.label("Only %s Affected" % ob.MhAffectOnly)
                else:
                    layout.label("Affect Only:")
                    layout.prop(ob, "MhAffectOnly", expand=True)
                    #layout.operator("mh.delete_irrelevant")  
                

        if rig and rig.type == 'ARMATURE':
            layout.separator()
            layout.label("Export/Import MHP")
            layout.operator("mh.saveas_mhp")
            layout.operator("mh.load_mhp")

            layout.separator()
            layout.label("Export/Import BVH")
            layout.prop(scn, "MhExportRotateMode")
            layout.operator("mh.saveas_bvh")
            layout.operator("mh.load_bvh")

            layout.separator()
            layout.label("Convert between rig weights")
            layout.prop(scn, "MhSourceRig")
            layout.prop(scn, "MhTargetRig")
            layout.prop(scn, "MhPoseTargetDir")            
            layout.operator("mh.convert_rig")
Пример #13
0
    def draw(self, context):
        layout = self.layout
        ob = context.object
        if ob:
            rig = ob.parent
        else:
            rig = None
        scn = context.scene
        if not utils.drawConfirm(layout, scn):
            return
            
        settings.drawDirectories(layout, scn)

        if False:
            layout.label("Pruning")
            row = layout.row()
            row.prop(ob, "MhPruneEnabled")
            row.prop(ob, "MhPruneWholeDir")
            row.prop(ob, "MhPruneRecursively")
            layout.operator("mh.prune_target_file")

        layout.label("Load materials from")
        layout.prop(scn, "MhLoadMaterial", expand=True)
        layout.separator()
        if utils.isBaseOrTarget(ob):
            layout.operator("mh.import_base_mhclo", text="Reimport Base Mhclo").delete = True
            layout.operator("mh.import_base_obj", text="Reimport Base Obj").delete = True
            #layout.operator("mh.delete_clothes")
            #layout.operator("mh.tights_only")
            layout.separator()
        else:
            layout.operator("mh.import_base_mhclo", text="Import Base Mhclo").delete = False
            layout.operator("mh.import_base_obj", text="Import Base Obj").delete = False
            if rig and rig.type == 'ARMATURE':
                layout.operator("mh.make_base_obj")

        if utils.isBase(ob):
            layout.operator("mh.new_target")
            layout.operator("mh.load_target")            
            layout.operator("mh.load_target_from_mesh")                        

        elif utils.isTarget(ob):
            if not ob.data.shape_keys:
                layout.label("Warning: Internal inconsistency")
                layout.operator("mh.fix_inconsistency")
                return
            layout.separator()
            layout.prop(ob, "show_only_shape_key")
            box = layout.box()
            n = 0
            for skey in ob.data.shape_keys.key_blocks:
                if n == 0:
                    n += 1
                    continue
                row = box.row()
                if n == ob.active_shape_key_index:
                    icon='LAMP'
                else:
                    icon='X'
                row.label("", icon=icon)
                row.prop(skey, "value", text=skey.name)
                n += 1

            layout.separator()
            layout.operator("mh.new_target", text="New Secondary Target")
            layout.operator("mh.load_target", text="Load Secondary From File")            
            layout.operator("mh.load_target_from_mesh", text="Load Secondary From Mesh")                        
            layout.operator("mh.fit_target")
            layout.separator()
            layout.operator("mh.discard_target")
            layout.operator("mh.discard_all_targets")
            layout.operator("mh.apply_targets")

            layout.separator()
            if ob.MhIrrelevantDeleted:
                layout.label("Only %s Affected" % ob.MhAffectOnly)
            else:
                layout.label("Affect Only:")
                layout.prop(ob, "MhAffectOnly", expand=True)
                layout.operator("mh.delete_irrelevant")  
            row = layout.row()
            row.prop(ob, "SelectedOnly")
            row.prop(ob, "MhZeroOtherTargets")
            if ob["FilePath"]:
                layout.operator("mh.save_target")           
            layout.operator("mh.saveas_target")       
            
            layout.separator()
            layout.label("Editing")
            layout.operator("mh.symmetrize_target", text="Symm Left->Right").action = "Left"
            layout.operator("mh.symmetrize_target", text="Symm Right->Left").action = "Right"
            layout.operator("mh.symmetrize_target", text="Mirror Target").action = "Mirror"
            if ob.MhAffectOnly == 'Skirt':
                layout.operator("mh.snap_waist")
                layout.operator("mh.straighten_skirt")
                
            layout.operator("mh.relax_selected")
            if ob.MhRelaxing:
                layout.prop(ob, "MhRelaxAmount")
                row = layout.row()
                row.prop(ob, "MhRelaxX")
                row.prop(ob, "MhRelaxY")
                row.prop(ob, "MhRelaxZ")
                layout.operator("mh.test_relax")
                layout.operator("mh.discard_relax")
                layout.operator("mh.commit_relax")
                layout.operator("mh.commit_and_relax_more")
                return

        if rig and rig.type == 'ARMATURE':
            layout.separator()
            layout.label("Export/Import MHP")
            layout.operator("mh.saveas_mhp")
            layout.operator("mh.load_mhp")

            layout.separator()
            layout.label("Export/Import BVH")
            layout.prop(scn, "MhExportRotateMode")
            layout.operator("mh.saveas_bvh")
            layout.operator("mh.load_bvh")

            layout.separator()
            layout.label("Convert between rig weights")
            layout.prop(scn, "MhSourceRig")
            layout.prop(scn, "MhTargetRig")
            layout.prop(scn, "MhPoseTargetDir")            
            layout.operator("mh.convert_rig")
Пример #14
0
    def draw(self, context):
        layout = self.layout
        ob = context.object
        if ob:
            rig = ob.parent
        else:
            rig = None
        scn = context.scene
        if not utils.drawConfirm(layout, scn):
            return

        settings.drawDirectories(layout, scn)

        if False:
            layout.label("Pruning")
            row = layout.row()
            row.prop(ob, "MhPruneEnabled")
            row.prop(ob, "MhPruneWholeDir")
            row.prop(ob, "MhPruneRecursively")
            layout.operator("mh.prune_target_file")

        layout.label("Load materials from")
        layout.prop(scn, "MhLoadMaterial", expand=True)
        layout.separator()
        if utils.isBaseOrTarget(ob):
            layout.operator("mh.import_base_mhclo",
                            text="Reimport Base Mhclo").delete = True
            layout.operator("mh.import_base_obj",
                            text="Reimport Base Obj").delete = True
            #layout.operator("mh.delete_clothes")
            #layout.operator("mh.tights_only")
            layout.separator()
        else:
            layout.operator("mh.import_base_mhclo",
                            text="Import Base Mhclo").delete = False
            layout.operator("mh.import_base_obj",
                            text="Import Base Obj").delete = False
            if rig and rig.type == 'ARMATURE':
                layout.operator("mh.make_base_obj")

        if utils.isBase(ob):
            layout.operator("mh.new_target")
            layout.operator("mh.load_target")
            layout.operator("mh.load_target_from_mesh")

        elif utils.isTarget(ob):
            if not ob.data.shape_keys:
                layout.label("Warning: Internal inconsistency")
                layout.operator("mh.fix_inconsistency")
                return
            layout.separator()
            layout.prop(ob, "show_only_shape_key")
            box = layout.box()
            n = 0
            for skey in ob.data.shape_keys.key_blocks:
                if n == 0:
                    n += 1
                    continue
                row = box.row()
                if n == ob.active_shape_key_index:
                    icon = 'LAMP'
                else:
                    icon = 'X'
                row.label("", icon=icon)
                row.prop(skey, "value", text=skey.name)
                n += 1

            layout.separator()
            layout.operator("mh.new_target", text="New Secondary Target")
            layout.operator("mh.load_target", text="Load Secondary From File")
            layout.operator("mh.load_target_from_mesh",
                            text="Load Secondary From Mesh")
            layout.operator("mh.fit_target")
            layout.separator()
            layout.operator("mh.discard_target")
            layout.operator("mh.discard_all_targets")
            layout.operator("mh.apply_targets")

            layout.separator()
            if ob.MhIrrelevantDeleted:
                layout.label("Only %s Affected" % ob.MhAffectOnly)
            else:
                layout.label("Affect Only:")
                layout.prop(ob, "MhAffectOnly", expand=True)
                layout.operator("mh.delete_irrelevant")
            row = layout.row()
            row.prop(ob, "SelectedOnly")
            row.prop(ob, "MhZeroOtherTargets")
            if ob["FilePath"]:
                layout.operator("mh.save_target")
            layout.operator("mh.saveas_target")

            layout.separator()
            layout.label("Editing")
            layout.operator("mh.symmetrize_target",
                            text="Symm Left->Right").action = "Left"
            layout.operator("mh.symmetrize_target",
                            text="Symm Right->Left").action = "Right"
            layout.operator("mh.symmetrize_target",
                            text="Mirror Target").action = "Mirror"
            if ob.MhAffectOnly == 'Skirt':
                layout.operator("mh.snap_waist")
                layout.operator("mh.straighten_skirt")

            layout.operator("mh.relax_selected")
            if ob.MhRelaxing:
                layout.prop(ob, "MhRelaxAmount")
                row = layout.row()
                row.prop(ob, "MhRelaxX")
                row.prop(ob, "MhRelaxY")
                row.prop(ob, "MhRelaxZ")
                layout.operator("mh.test_relax")
                layout.operator("mh.discard_relax")
                layout.operator("mh.commit_relax")
                layout.operator("mh.commit_and_relax_more")
                return

        if rig and rig.type == 'ARMATURE':
            layout.separator()
            layout.label("Export/Import MHP")
            layout.operator("mh.saveas_mhp")
            layout.operator("mh.load_mhp")

            layout.separator()
            layout.label("Export/Import BVH")
            layout.prop(scn, "MhExportRotateMode")
            layout.operator("mh.saveas_bvh")
            layout.operator("mh.load_bvh")

            layout.separator()
            layout.label("Convert between rig weights")
            layout.prop(scn, "MhSourceRig")
            layout.prop(scn, "MhTargetRig")
            layout.prop(scn, "MhPoseTargetDir")
            layout.operator("mh.convert_rig")
Пример #15
0
def discardAllTargets(context):
    ob = context.object
    while utils.isTarget(ob):
        discardTarget(context)
    return
Пример #16
0
def discardAllTargets(context):
    ob = context.object
    while utils.isTarget(ob):
        discardTarget(context)
    return
Пример #17
0
    def draw(self, context):
        layout = self.layout
        ob = context.object
        if ob:
            rig = ob.parent
        else:
            rig = None
        scn = context.scene
        if not utils.drawConfirm(layout, scn):
            return

        if Thomas:
            layout.label("Pruning")
            row = layout.row()
            row.prop(ob, "MhPruneEnabled")
            row.prop(ob, "MhPruneWholeDir")
            row.prop(ob, "MhPruneRecursively")
            layout.operator("mh.prune_target_file")

        if not utils.isBaseOrTarget(ob):
            layout.operator("mh.import_base_obj")
            layout.operator("mh.import_base_mhclo")
            layout.operator("mh.make_base_obj")

        elif utils.isBase(ob):
            layout.label("Load Target")
            layout.operator("mh.new_target")
            layout.operator("mh.load_target")
            layout.operator("mh.load_target_from_mesh")

        elif utils.isTarget(ob):
            if not ob.data.shape_keys:
                layout.label("Warning: Internal inconsistency")
                layout.operator("mh.fix_inconsistency")
                return
            layout.separator()
            box = layout.box()
            n = 0
            for skey in ob.data.shape_keys.key_blocks:
                if n == 0:
                    n += 1
                    continue
                row = box.row()
                if n == ob.active_shape_key_index:
                    icon = 'LAMP'
                else:
                    icon = 'X'
                row.label("", icon=icon)
                row.prop(skey, "value", text=skey.name)
                n += 1

            layout.label("Load Target")
            layout.operator("mh.new_target", text="New Secondary Target")
            layout.operator("mh.load_target", text="Load Secondary From File")
            layout.operator("mh.load_target_from_mesh",
                            text="Load Secondary From Mesh")
            ext = os.path.splitext(ob.MhFilePath)[1]
            if ext == ".mhclo":
                layout.operator("mh.fit_target")

            layout.label("Discard And Apply Target")
            layout.operator("mh.discard_target")
            layout.operator("mh.discard_all_targets")
            layout.operator("mh.apply_targets")

            layout.label("Symmetry")
            row = layout.row()
            row.operator("mh.symmetrize_target",
                         text="Left->Right").action = "Left"
            row.operator("mh.symmetrize_target",
                         text="Right->Left").action = "Right"
            if Thomas:
                row.operator("mh.symmetrize_target",
                             text="Mirror").action = "Mirror"

            layout.label("Save Target")
            layout.prop(ob, "SelectedOnly")
            layout.prop(ob, "MhZeroOtherTargets")
            if ob["FilePath"]:
                layout.operator("mh.save_target")
            layout.operator("mh.saveas_target")

            if not ob.MhDeleteHelpers:
                layout.label("Skirt Editing")
                layout.operator("mh.snap_waist")
                layout.operator("mh.straighten_skirt")
                if ob.MhIrrelevantDeleted:
                    layout.separator()
                    layout.label("Only %s Affected" % ob.MhAffectOnly)
                else:
                    layout.label("Affect Only:")
                    layout.prop(ob, "MhAffectOnly", expand=True)
                    #layout.operator("mh.delete_irrelevant")

        if rig and rig.type == 'ARMATURE':
            layout.separator()
            layout.label("Export/Import MHP")
            layout.operator("mh.saveas_mhp")
            layout.operator("mh.load_mhp")

            layout.separator()
            layout.label("Export/Import BVH")
            layout.prop(scn, "MhExportRotateMode")
            layout.operator("mh.saveas_bvh")
            layout.operator("mh.load_bvh")

            layout.separator()
            layout.label("Convert between rig weights")
            layout.prop(scn, "MhSourceRig")
            layout.prop(scn, "MhTargetRig")
            layout.prop(scn, "MhPoseTargetDir")
            layout.operator("mh.convert_rig")
Пример #18
0
    def draw(self, context):
        layout = self.layout
        ob = context.object
        if ob:
            rig = ob.parent
        else:
            rig = None
        scn = context.scene
        if not utils.drawConfirm(layout, scn):
            return
        settings.drawDirectories(layout, scn)

        layout.label("Load materials from")
        layout.prop(scn, "MhLoadMaterial", expand=True)
        layout.separator()
        if utils.isBaseOrTarget(ob):
            layout.operator("mh.import_base_mhclo", text="Reimport Base Mhclo").delete = True
            layout.operator("mh.import_base_obj", text="Reimport Base Obj").delete = True
            layout.operator("mh.delete_clothes")
            layout.separator()
        else:
            layout.operator("mh.import_base_mhclo", text="Import Base Mhclo").delete = False
            layout.operator("mh.import_base_obj", text="Import Base Obj").delete = False
            if rig and rig.type == "ARMATURE":
                layout.operator("mh.make_base_obj")
        if utils.isBase(ob):
            layout.operator("mh.new_target")
            layout.operator("mh.load_target")
            layout.operator("mh.load_target_from_mesh")
        elif utils.isTarget(ob):
            if not ob.data.shape_keys:
                layout.label("Warning: Internal inconsistency")
                layout.operator("mh.fix_inconsistency")
                return
            layout.separator()
            layout.prop(ob, "show_only_shape_key")
            box = layout.box()
            n = 0
            for skey in ob.data.shape_keys.key_blocks:
                if n == 0:
                    n += 1
                    continue
                row = box.row()
                if n == ob.active_shape_key_index:
                    icon = "LAMP"
                else:
                    icon = "X"
                row.label("", icon=icon)
                row.prop(skey, "value", text=skey.name)
                n += 1
            layout.separator()
            layout.operator("mh.new_target", text="New Secondary Target")
            layout.operator("mh.load_target", text="Load Secondary From File")
            layout.operator("mh.load_target_from_mesh", text="Load Secondary From Mesh")
            layout.operator("mh.fit_target")
            layout.operator("mh.symmetrize_target", text="Symm Left->Right").left2right = False
            layout.operator("mh.symmetrize_target", text="Symm Right->Left").left2right = True
            # layout.separator()
            # layout.prop(scn, '["Relax"]')
            # layout.operator("mh.relax_target")
            layout.separator()
            layout.operator("mh.discard_target")
            layout.operator("mh.discard_all_targets")
            layout.separator()
            layout.operator("mh.apply_targets")
            layout.separator()
            layout.prop(ob, '["SelectedOnly"]')
            if ob["FilePath"]:
                layout.operator("mh.save_target")
            layout.operator("mh.saveas_target")

        if rig and rig.type == "ARMATURE":
            layout.separator()
            layout.operator("mh.saveas_bvh")
            layout.operator("mh.load_bvh")