Maybe you can keep all vertex weight map for different type rig (Def, MHX, Rigfy)

Issue #614 closed
engetudouiti created an issue

It related with your blog topic, (mimic clothing library) .

I have not seirouly planed to keep all vertex group, but today I test more. Then I think, when you convert rig to MHX (or rig-fy) you can copy current vertex group (but only about deform related vertex group = only copy current rig bone name vertex group)

if I use bpy.ops.copy , it auto add suffix as Bonename_copy. but I think you can set name as you need, untill convert mhx.

then the weight only used if there is bone the name = bonename_copy , so untill user change bone, or change the copy vertex group name it not effect, current rig pose.

1. user click convert to mhx

2. copy all vertex group of default rig bone name first, then only rename them like bonename_daz (after all without there is “bonename_daz” bone, it never work = it not effect by any rig pose) so at this point, it just keep vertex group (but not used)

But once keep vertex gorup of current rig bone, with different name (add suffix like _DAZ or mhx or rf)

I suppose we can use same object (and data) for all converted rig = we do not need to keep mesh for each type but swap the vertex group for posing (with return name to fit for current rig)

Though most of user may decide, their rig type. then only concern to keep the mesh which work for the rig (def or mhx or rig-fy)

But I sometimes need to use def rig and def mesh. of course if mesh have changed when convert, we may see the difference, and There remain, problem which change driver target for current rig type,

but I think, as first step, you can make option, which keep all vertex group (related pose only) when convert as different name with set prefix. then as future, there will be function, return vertex group name for default rig <> MHX (or rig fy) rig

about all case, you only need to copy vertex group with prefix, or manipulate vertex group name which add on already generated. then when user change armature modifier target rig, the mesh can deform with current rig pose bone.

So as first usable function, (I suppose to use)

  1. option which can copy pose bone vertex group as _DAZ when (untill) convert MHX.
  2. function which return vertex group (_DAZ) name to DAZ (default) rig, with keep MHX bone vertex group as _MHX.
  3. function which exchange vertex group of DAZ rig <> MHX rig.

the mesh will have 2 vertex group set , then only the vertex group name suffix change witch fit for current rig. (one is just to keep another type rig , one is actually used for current rig = no suffix

Comments (9)

  1. engetudouiti reporter

    Then of course you need not use bpy.ops but can use vertexgroup.copy() I suppose.

    though I may need to test to confirm how it work.. anyway base idea is same.

    (keep current bone vertex group as rig type name, then offer rename function for 2 type rig)

    I may hope you consider, when you find time to try this. it may offer compatible clothing (at least user can easy swap mesh for rig- type without append or exchange but only change vertex group names)

  2. engetudouiti reporter

    You may test it work with these step.

    1. copy vertex group of one pose bone name.
    2. delete original bone vertex group
    3. pose the bone >> it not deform
    4. rename the vertex group of bone _copy to bone. then pose bone
    5. it should work

    I may need to test it when actually change armature modifier target rig, but I suppose basically it should work. so only matter is how you make it as script to user easy use ^^;

    at same time I suppose we can use lock vertex group for those copy group. (so we can keep default rig vertex group or MHX rig vertex group safety, when it is not used for current rig)

  3. engetudouiti reporter

    Hm I made test script, which generate _DAZ and _MHX for meshes with current selection.

    Then once generate these vertex groups for 2 type rig, (untill convert MHX, and after convert MHX) to protect, I made another function which remove the suffix with current active rig. at same time it re-generate _DAZ or _MHX group to protect them.

    So all mesh keep 3 set vertex groups, one is to deform with current rig, (non suffix) and _DAZ , _MHX vertex gorups to keep those vertex group.

    But I can not find good way to avoid bpy.ops.copy.vertex_group . then it took long time to generate all deform bone vertex group (duplicate and rename ^^;)

    eg for 3 body mesh (non merged body, merged body, grafted part) and 2 under wear, I need 2 minutes more to generate (copy) all deform vertex group with suffix. (duplicate) Though I suppose, most of time used to copy face bone vertex group.

    like this (it is tops so not have many vertex group for pose)

    I plan just rename or remove suffix , once generate 2 set vertex group, so mesh may only need to keep 2 sets, but it seems unstable when user often change rig. and I need to keep non deform vertex group without rename.

    I suppose if I can copy vertex group (but set different name) for each mesh without use bpy.ops, it fast enough, (with use bpy.ops I do not think you like it, because of take long time untill finish to copy all vertex group)

    As future plan, I may keep 2 armature data, (MHX, and DAZ), as library, then may auto rename mesh vertex group with curent data type. (so I may not need to change armature modifer, but still need to change driver target of morphs and can not confrim it work or not,,)

    at current, if I simply swap rig (generate 2 rig with append), then use your offered function “ retarget armature” + retarget driver (I customize it because your function is too strict to check rig propertys are same ,if not cause error ) it seems work for me.

    Though I afraid if there will be case, some morph driver break..

  4. engetudouiti reporter

    I tweak my test code, duplicate twice take more time, so now generate duplicate vertex group only need once untill change as MHX. then when change rig MHX to daz, it rename MHX vertex group as _MHX, then remove _DAZ when retrun to MHX do reverse thing. (so one mesh usually keep 2 vertex group set, for current rig and keep with suffix)

    It can change with current selection and active rig type. the only problem is, I need to set new list ID props for non deform vertex group untill use convert vertex group. (like smooth modifier etc), or it try to rename those non deform vertex group , then modifier not work )

    To check non deform vertex gorup and generate as list, I need to select current rig. (then exclude non deform vertex group),

    after that select target rig (eg MHX) then convert vertex group name.

    If there is case user hope to keep mesh for 2 rig type with out duplicate them, and keep them as library, add on will offer such function which can exchange vertex group name for current select rig, may be useful. at current I keep all clothing mesh as compatible type (remain daz rig vertex group as _DAZ but use for MHX rig) without duplicate mesh.

  5. Thomas Larsson repo owner

    This looks quite complicated, and keeping multiple vertex groups would be wasteful too. My own workflow is to keep a library of outfits with daz rigs. To make the final character, I assemble the nude character and the clothes I want to use in a new file, and convert everything to mhx. Works for me with the tools already available.

  6. engetudouiti reporter

    I agree your way is clear and work well. I have made library (for clothing) as you described before. So not push it . (I close this topic)

    at same time why I make those func and use , Most case I only work with MHX scene, I often hope to change items (all character items have been converted already for current scene. but I hope to exchange items.

    So to add (eg change armor or T shirt etc) items for MHX rig, you may need to convert daz item with another rig. then append to current scene I suppose. The step is not so quick. without you always keep 2 rig in the scene.

    Then I have generated 2 type meshes (def and mhx) for library to quick exchange items. = it actually need double size but can quick add items without convert process.

    As you said Keep 2 vertex group set for each mesh need more data than one vertex group sets for one item.

    but once you convert MHX with clothing in real working scene, everytime you can add or exchange items directly. at same time if you need to return daz rig mesh I can do it without serch default mesh. (just need rig to change target) So I actually added those func for my custom add on , then force myself to keep MHX items as library witch keep both vertex group sets. So my library only have one compatible meshes (deform by MHX) . but if I hope to clean play scene mesh, I use remove those suffix vertex group later. (for lbirary it always keep 2 vertex group)

  7. Log in to comment