コード例 #1
0
def loadTargetFromMesh(context):
    ob = context.object
    if not utils.isBaseOrTarget(ob):
        raise NameError("Active object %s is not a base object" % ob.name)
    scn = context.scene
    trg = None
    for ob1 in scn.objects:
        if ob1.select and ob1.type == 'MESH' and ob1 != ob:
            trg = ob1
            break
    if not trg:
        raise NameError("Two meshes must be selected")
    bpy.ops.object.mode_set(mode='OBJECT')

    scn.objects.active = trg
    bpy.ops.object.transform_apply(location=False, rotation=True, scale=True)

    scn.objects.active = ob
    name = trg.name
    skey = ob.shape_key_add(name=name, from_mix=False)
    ob.active_shape_key_index = utils.shapeKeyLen(ob) - 1
    skey.name = name
    nVerts = len(ob.data.vertices)
    for v in trg.data.vertices[0:nVerts]:
        skey.data[v.index].co = v.co
    skey.slider_min = -1.0
    skey.slider_max = 1.0
    skey.value = 1.0
    ob.show_only_shape_key = False
    ob.use_shape_key_edit_mode = True
    ob["NTargets"] += 1
    ob["FilePath"] = 0
    ob.SelectedOnly = False
    scn.objects.unlink(trg)
    return
コード例 #2
0
ファイル: maketarget.py プロジェクト: Iffar/makehuman_datagen
def loadTargetFromMesh(context):
    ob = context.object
    if not utils.isBaseOrTarget(ob):
        raise NameError("Active object %s is not a base object" % ob.name)
    scn = context.scene
    trg = None
    for ob1 in scn.objects:
        if ob1.select and ob1.type == 'MESH' and ob1 != ob:
            trg = ob1
            break
    if not trg:
        raise NameError("Two meshes must be selected")        
    bpy.ops.object.mode_set(mode='OBJECT')
    
    scn.objects.active = trg
    bpy.ops.object.transform_apply(location=False, rotation=True, scale=True)

    scn.objects.active = ob
    name = trg.name
    skey = ob.shape_key_add(name=name, from_mix=False)
    ob.active_shape_key_index = utils.shapeKeyLen(ob) - 1
    skey.name = name
    nVerts = len(ob.data.vertices)
    for v in trg.data.vertices[0:nVerts]:
        skey.data[v.index].co = v.co
    skey.slider_min = -1.0
    skey.slider_max = 1.0
    skey.value = 1.0
    ob.show_only_shape_key = False
    ob.use_shape_key_edit_mode = True
    ob["NTargets"] += 1
    ob["FilePath"] = 0
    ob.SelectedOnly = False
    scn.objects.unlink(trg)
    return
コード例 #3
0
ファイル: __init__.py プロジェクト: RuliLG/makehuman
    def draw(self, context):
        layout = self.layout
        ob = context.object
        scn = context.scene
        if not utils.drawConfirm(layout, scn):
            return
        settings.drawDirectories(layout, scn)

        if utils.isBaseOrTarget(ob):
            for (label, names) in mhm.MhmDisplay:
                layout.label(label)
                for name in names:
                    prop = mhm.MhmNameProps[name]
                    split = layout.split(0.8)
                    split.prop(ob.data, prop)
                    split.operator("mh.update_all_sliders")
            layout.separator()                
            layout.operator("mh.update_all_sliders")        
            layout.operator("mh.reset_all_sliders")        
            layout.operator("mh.load_mhm_file")                        
            layout.operator("mh.discard_all_targets")
コード例 #4
0
ファイル: __init__.py プロジェクト: michelamorim/makehuman
    def draw(self, context):
        layout = self.layout
        ob = context.object
        scn = context.scene
        if not utils.drawConfirm(layout, scn):
            return
        settings.drawDirectories(layout, scn)

        if utils.isBaseOrTarget(ob):
            for (label, names) in mhm.MhmDisplay:
                layout.label(label)
                for name in names:
                    prop = mhm.MhmNameProps[name]
                    split = layout.split(0.8)
                    split.prop(ob.data, prop)
                    split.operator("mh.update_all_sliders")
            layout.separator()
            layout.operator("mh.update_all_sliders")
            layout.operator("mh.reset_all_sliders")
            layout.operator("mh.load_mhm_file")
            layout.operator("mh.discard_all_targets")
コード例 #5
0
ファイル: __init__.py プロジェクト: Iffar/makehuman_datagen
    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")
コード例 #6
0
ファイル: __init__.py プロジェクト: RuliLG/makehuman
    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")
コード例 #7
0
ファイル: __init__.py プロジェクト: michelamorim/makehuman
    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")
コード例 #8
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")
コード例 #9
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")