Semiautomatic Weight Transfer - Ezekial711/MonsterHunterWorldModding GitHub Wiki
The following script will convert the listed weight groups on each selected mesh into a weight group that has the Bone Function ID provided by the mapping. Bone Function ID tables can be found here. Script thanks to AsteriskAmpersand.
Modify the namelist variable to include the weight group names from your model and the function id they should be mapped to.
import bpy
def weightMod(object, mhwGroup, sourceGroup):
name = "%s - %s"%(mhwGroup,sourceGroup)
#"Bone."+str(int(mod.name.split(".")[1])+7)+".000"
m = object.modifiers.new(name = name, type = "VERTEX_WEIGHT_MIX")
if mhwGroup not in object.vertex_groups:
object.vertex_groups.new(mhwGroup)
m.vertex_group_a = mhwGroup
m.vertex_group_b = sourceGroup
m.mix_mode = "ADD"
m.mix_set = "OR"
name_list = {
"Head Head":4,
"Body Extra Spine2":4
}
emptyNames = {}
for obj in [sel for sel in C.scene.objects if sel.type == "EMPTY"]:
if "boneFunction" in obj:
emptyNames[obj["boneFunction"]] = obj.name
for obj in [sel for sel in C.scene.objects if sel.type == "MESH"]:
v_groups = obj.vertex_groups
for n in name_list:
if n in v_groups and name_list[n] in emptyNames:
weightMod(obj, emptyNames[name_list[n]], v_groups[n].name)
For example, let's say I want to convert "Head Head" and "Body Extra Spine2" to a single group, and I want it to be the one used by the Head (bone function 04)
name_list = {
"Head Head":4,
"Body Extra Spine2":4
}
You need to have a world skeleton already present. The script will look on the skeleton what bone has the boneFunctionID of 4 and will rename the two groups above to the bone that has that function ID (in this case it was Bone.002). It does that by creating the WeightMixModifiers.