small script to adjust MHX g3 rig foot toe pose clean

Issue #534 resolved
engetudouiti created an issue

I am main G3 user so, daz small toe driver is always problem for me. I asked it for Thomas, then he kindly add driver or constrain as option, for each version, but once convert MHX usually it cause new issue for the smart IK reverse foot.

So I gave up the idea, before. (usually you do not care how small toes deform,, with foot pose, so it only matter for toe mania or user how render small toes bend pose (usually night version render, no one care how toes bend I understand,, šŸ˜Œ )

But I usually like to render such pose or scene,, so it is important then I still try to manage it only for my purose.

With recent snap issue commit, I happend to find even though I add those constrain for small toes and represent daz way, now it work without problem. (snap IK <> FK work perfect) but the way have pro and con, so I made script, user can easy change night version (better FK IK posing for toe deform) or foot wear version (too get best reverse IK foot, you may choose it)

I dscribe pro and con, in script, so if someone think G3 MHX foot toe pose not good even though you try to import all jcms,, when bend, try it. (just load this script ,and select rig, then change option, and run it for G3 MHX (non toe merge option!!!)

The difference is like this

ā€Œ

then load script, select MHX G3 rig, run it. (check description, to comment out and choose option)

now it add new constrain for small toes and change parent, , then anyway it work like this

ā€Œ

you can anytime return with use another option, (select rig then run again), it remove added constrain, and set bone hieralchy as default.

I describe detail, and how to use it so use it as you like. it is too miner thing, so I do not request it to include thomas add on it is just for G3 MHX (non merge toe) and toes deform mania..

it may work well for both FK, IK mode and to import pose or when you import foot wear (because daz made G3 foot toes so, then deform more look like daz way) of course you can still manipulate each small toes more good adjustment. (so you do not merge toes)

ā€Œ

import bpy

""" script purpose (Pro and Con)

Pro :     
Only For Thomas daz importer G3 MHX converted rig witch not Merge Toes, 
to get reasonable toes deform.
this script just add new constrains for small toes, and change small toes parent 
as tarsal. so it can rotate each small toes with each pivot when Large toe (controller) bend.

It can show better deform when rotate master toe bones 
(with FK = toe.fk and IK = foot.rev bones) to bend small toes. 

it will effect your foot wear deform too. Though toes set constrain, 
you can still pose each small toes to get more detail posing.

Con : 
To get MHX IK reverse foot which auto pose toes, pivot should be locate on toe head 
position. Then when you rotate "foot.rev bone", small toes change Up down slightly 
with toe angle. because script try to use each small toe pivot to get better deform 
(Daz g3 figure weight for bone so, then it show best defrom when small toe rotate 
with each pivot, not Toe pivot (which is controller to rotate each small toes)

Then if you need to keep small toes position when rotate foot.rev.L with IK mode, 
for best IK foot contact, you may better return rig by g3_toe_constset(flg = False) 
of this script then run again. it return rig as default MHX G3 toes

how to use?: 

1. Change the last function setting option opt = True or False
 with remove # comment out mark 

g3_toe_constset(flg = True) add new constrain for small toe with change parent bone
g3_toe_constset(flg = False) remove constrain only about this script added and retrun default MHX toe (G3)

2. select MHX g3 rig (**not merge toes**) then run script

you can use those 2 function whenever you need for G3 MHX **non merged toes** , 
and can convert / return for each purpose"""    

ob = bpy.context.active_object
ltoe_names = ["big_toe.01.L", "small_toe_1.01.L", "small_toe_2.01.L", "small_toe_3.01.L", "small_toe_4.01.L"]
rtoe_names = ["big_toe.01.R", "small_toe_1.01.R", "small_toe_2.01.R", "small_toe_3.01.R", "small_toe_4.01.R"]
toe_names = ltoe_names + rtoe_names

def set_toe_parents(flg):
    bpy.ops.object.mode_set (mode='EDIT')
    ebns = ob.data.edit_bones
    if flg:
        lptb = ebns["tarsal.L"]
        rptb = ebns["tarsal.R"]
    else:
        lptb = ebns["toe.L"]
        rptb = ebns["toe.R"]

    for name in ltoe_names:
        ebns[name].parent = lptb
        ebns[name].use_connect = False

    for name in rtoe_names:
        ebns[name].parent = rptb
        ebns[name].use_connect = False

def set_const_attribute(pbns, name, strg):
    if "CustomToeConst" not in pbns[name].constraints.keys():
        cst = pbns[name].constraints.new('COPY_ROTATION')
        cst.name = "CustomToeConst"
        cst.target = ob
        cst.subtarget = strg
        cst.euler_order ='YZX'
        cst.use_x = True
        cst.use_y = False
        cst.use_z = True
        cst.mix_mode = 'BEFORE'
        cst.target_space = 'LOCAL'
        cst.owner_space = 'LOCAL'
        cst.influence = 1

def set_toe_constrains():
    bpy.ops.object.mode_set(mode='POSE')    
    pbns = ob.pose.bones

    rstg = "toe.R"
    lstg = "toe.L"

    for name in rtoe_names:
        set_const_attribute(pbns, name, rstg)
    for name in ltoe_names:
        set_const_attribute(pbns, name, lstg)

def remove_toe_constrains():
    bpy.ops.object.mode_set(mode='POSE')
    pbns = ob.pose.bones
    for name in toe_names:
        pbn = pbns[name]
        csts = pbn.constraints
        if "CustomToeConst" in csts.keys():
            csts.remove(csts["CustomToeConst"])

def g3_toe_constset(flg = True):
    cmode = ob.mode
    set_toe_parents(flg)

    if flg:
        set_toe_constrains()
    else:
        remove_toe_constrains()

    bpy.ops.object.mode_set(mode=cmode) 

"""
=========================================================
1. remove comment out mark "#" for below "opt" setting True/False with current purpose
2. run script with select G3 MHX rig (pose mode is best to see effect)
=========================================================
"""

#To add new constrain and reparent toes to tarsal as same as daz G3"            
opt = True

#To remove script added constrains and return small toes parents as Toe bone"
#opt = False

g3_toe_constset(flg = opt)

ā€Œ

Of course if you test it, with keep original blend scene. (though with my test, I do not see any issue, when convert or return to original, anyway better keep original scene when use new script)

Comments (12)

  1. Thomas Larsson repo owner

    The copy rotations constraints are implemented in the last commit. The influence is controlled by the ToeTarsal slider (hm, not the best of names). I also moved the tarsal and heel bones to the Toe layer, so you have all foot tweak bones in the same layer. Not sure if this does everything you wanted.

  2. engetudouiti reporter

    Thomas no, though you set constrain for Toe rotation, but small toe parented with Toe controll bone as same as before

    so after all small toes rotate with the Toe pivot = it is not same as daz and not clean deform for small toes.

    In daz when you bend Toe bone, it rotate each small toe local only. these G3 small toes are not parented with the Toe controll. (daz use ERC, so I use constrain in blender to make it looks like)

    you may better to check it with FK mode.. then bend small toes with toe controller.

    To test with current add on MHX G3 rig, compare current rig bend toe controller, how small toes will rotate.

    and change parent for small toes (small_toe_X.01 L / R) from Toe to tarsal. (then keep copy rotation of Toe)

    latter show clean deform toe bend when you controll it by Toe bone. and actually I did so. >> (then when IK foot rev bone bend, small toe slightly up-down = Con)

    At current small toes are parented with Toe, so after all it not up-down but it not show clean original deform because they rotate with Toe controller (parent) as same as before. (no change + add constrain rotation locally)

    ā€Œ

  3. engetudouiti reporter

    Actually even though I change the new driver prop with keep set up, ToeTarsal slider, it not change deform (at least with IK and same pose), Though I do not know reason though, but without you change parent bone, for those small toe From current Toe bone to Tarsal , it not work. (then if you make so, it only work with when constrain weight = 1.00. because you can not change parent bone. (or you need to use un-stable bone constrain, then I do not think it work )

    So,, what I may hoped is,

    you offer new option,

    which change small toes parent as tarsal. and set copy rotation without weight slider (always = 1.00) (because other value not work). which can switch anytime user need.

    then default option is,, hide the constrain, (or remove it ) + need to return parent bone as Toe.

    though you can control or hide, constrain which added for small toe (as I did) by slider value, but you can not auto-change parent bone (same as you mentioned for stretch option on and off) without change bone to tarsal, this commit not offer merit ^^;

    ( If you offer it as toggle option, (same as stretch on and off) user will choose G3 mhx foot rig set-up, for night version = it deform bend clean small toes when use Toe pose controller, or Foot IK walk animation version = it may not show slightly up-down small toe with rev-toe pose) for each animation or scene purpose. without re-generate, or user need to manually set constrain, and change parent.

  4. engetudouiti reporter

    Thomas the merit to add constrain is change pivot for small toes. you can see even though I set new tarsal prop as 1.00(it is weight to set constrain = copy rotation of the Toe bone (controller). All small toes rotate with Toe bone pivot. so it not deform well (daz do not make small toes so)

    then without you change all small toe bones location with change weight map, it always show this defrom when we rotate Toe (bend or side )

    ā€Œ

    Then if I keep your set up of constrain (but slider weight should be 1.00) , and change small toe parent as tarsal, now each small toe can rotate with each pivot , with Toe bend. like this. In this pic I use my custom script, then it need not set add on generate same copy rotation constrain (so I remove it with set as 0) ,at current my script added constrain work as 1.00 (same constrain and same target = Toe and rotation mode)

    ā€Œ

    if you pose toes in daz studio , actually small toes rotate with individual bone. so it not show the first pic deform for small toes joint area. because small toe only rotate with their self pivot (so not parented with Toe pose bone)

    ā€Œ

    To show same deform for small toes when I bend Toe bone (we usually use it), I need to set small toe parent as Tarsal then. each small toe may copy rotation of Toe bone (it is almost same as daz do)

    So if you do not parent small toe, but only copy rotation, it not show merit. (just keep same deform + new constrain and slider)

    At same time, as I mentioned, if set rig as I described, then try to make toe contact pose, with foot rev IK bend (UP) , it slightly down small toe bones pos. (because rev foot IK pivot keep, toe pivot, I understand it can not avoid. (to it work I may need really complex thing for foot IK chain) It is only demerit of this set-up.

    ā€Œ

    So when I hope to avoid this issue, (eg I really need to keep all small toe position, as IK contact pose) I may hope to use default rig set -up (no constrain, but parented with Toe, then all small toe simply rotate with Toe pivot.)

    ā€Œ

  5. engetudouiti reporter

    Or I suppose if you make it so intentionally? That means if user hope to set rig so, you offer constrain switch and gather bones which need to set parent (change) as one layer. (yes it seems make things easy for me if I manually set parent or constrain) so with use constrain slider + user manually select those toe bones and change parent as you need case by case? If so I may make this closded (though I do not think user can understand the usage of constrain. Though as for me it not matter because I know what I need to do)

  6. engetudouiti reporter

    No. it seems you make new constrain which I do not expect (and do not know clear how it work)

    because you set copy rotation target as tarsal for all small toes .. I do not think small toe need to copy rotation of tarsal bone,,, ^^;

    my intention was

    1. set R and L small toes parent as tarsal. (from Toe)
    2. set copy rotation for those toes. which copy Toe rotaiton (x and z ) only. like this pic

    so when we bend or side-side Toe controller bone, small toes can rotate with individual pivot >> show more reasonable deform for G3 rig

    Then if you actually plan it to merge add on, I hope you can toggle this. but as start point, the new constrain seems have not meaning or may cause un-epxected rresult I suppose. (and I do not expect to controll small toes bend, rotate tarsal bone)

    ā€Œ

  7. Thomas Larsson repo owner

    OK, now I think I understand what you mean. Hopefully it should work now, although Iā€™m unsure how useful this is.

  8. engetudouiti reporter

    This set up can clean deform which current MHX default rig set up show when user rotate toe bone (control bone). (to bend small toes)

    if user do not think any difference for toes bend, between first pic (default MHX offered) and pic which set up so, (change parent + use toe constrain )

    they do not need it.

    As for me it show heavy difference, as same as when I use bend JCM for legs or not. . so I hope to use this set up when I need it or there is no meaning to import toes jcm at all because it can not correct such deform. (even though I apply smooth modifier, with default set up , all G3 actor show first pic bend for small toes kind of jammed toes with same angle.

  9. engetudouiti reporter

    Thanks now it correct constrain target, at same time if user need to see any difference ,,they need to change all small toes parent as Tarsal .without it , it not work. did you try actually do same thing what I mentioned? if not, or you actually check it as I mentioned, then think there seems no differnce for toe pose (you may use toe bone to bend small toes), I think you may beter not merge it. (I simply close this topic, and use custom script as my private purpose as same as before)

    ā€Œ

  10. engetudouiti reporter

    I now test again with new commit, and I miss use old ones (do not notice your recent up-date, or I do not update git corectly to new commit) sorry šŸ˜³

    thanks you take time. (though I can not say it is useful but for me it offer good toe pose for nude render) I often try many angle for such render, then it is important for me as same as someone need many gen morphs.

    ā€Œ

  11. Log in to comment