MHX rts snap IK to FK improvement to manage shin twist rotation well

Issue #509 resolved
engetudouiti created an issue

When use snap IK bones to FK bones, basically there should be different about shin and Thigh twist.

The reason is, when we pose IK legs, Thigh and Shin controlled by IK chain then IK can not free twist Shin bone.

(Though we can use tweak bones but it is not to pose twist for shin. (just deform with free move so not for the purpose)

On the other hand, with FK we can twist Shin bone as samd as daz do..

Then when we twist Shin in FK, and snap IK bones to FK , add on can not adjust FK shin twist correctly.

So to make it work, at first we need to add one controll bone for twist IK Shin only. (it not move foot like FK, but it is not matter, it is adjust shin twist as same as daz,, after we pose with IK foot. then adjust Shin twist (if we need).

Compare these 2 pic please.

with default IK chain we do not have any controller to twist Shin bone only. (Thing and shin twist by Foot IK so can not add twist for Shin)

Then add Shin.twist.IK bone. as child of Shin.IK. at same time with IK mode, Shin bone attach to Shin.twist.IK.

so now with IK mode we can add twist for Shin without restriction of IK chain. like this.

The merit is now we can controll IK Shin twist rotation as same as FK mode. That means, when snap IK to FK bones,

Though I do not know all step how add on try to snap IK chain to FK chain legs. but

  1. foot IK bones locate on FK foot bones.
  2. IK Thigh bone locate on FK Thigh >> auto set twist for Shin IK (we could not adjust it)
  3. New IK Shin twist bone can rotate free, then locate on FK shin.

should offer more reasonable Snap IK to FK chain.

Even though if it remain problem (add on will not fit IK Thigh but fit IK shin first, so Thigh show twist remain problem)

at least new IK twist Shin bone offer free adjust Shin twist as same as FK, after all it will show more reasnable snap than current IK MHX (snap to FK which can free twist Shin with limit)

To set up it,

  1. duplicate Shin.IK in edit mode , and rename as Shin.IK.tws (R / L)
  2. set Shin.IK.tws(R / L) parent as Shin.IK and remove all constrain for the Shin.IK.tws (R / L) (auto duplicated)
  3. set limit for Y axis only.. (or simply use lock for X and Z rotation as Euler)

After confirm IK chain move, (now you can free twist Shin

4. Select Shin (L/R) then Change 2nd Constrain (copy transform) target (IK) from Shin.IK to Shin.IK.tws (R/ L)

so with IK mode, shin (L /R) copy transform of the new Shin.IK.tws (R/ L) then can keep all IK move and deform as same as before. it only add free twist (local Y axis) Shin deform for IK mode.

How use the new IK shin tws bone for snap IK to FK may need to ask Thomas though… and if Thomas confirm it work well the new Shin IK twist widgt may need as default. (it is not twk bone.. it is to twist Shin with IK only with limit) , though it not matter user seldom use it or not.. because with Snap IK to FK (and FK to IK) after all the new bone need )

Comments (8)

  1. engetudouiti reporter

    And I suppose after add new IK.shin.twist,

    FK snap to IK need to change,, (FK shin bone need to locate on new IK.shin.tws)

    or when you change mode, the IK shin twist added rotation are ignored.

    And even though it can not auto snap IK to FK perfectly still, the good thing is now I adjust the twist rotation with IK mode, so when I need to snap IK to FK, I can adjust IK twist Shin manually = it may not show hard difference, when change mode FK to IK. (FK used the shin twist). without it, we do not have way to avoid sudden twist shin. (it return to IK chain)

  2. engetudouiti reporter

    Yes actually it worked for me. with my test script (it need to apply after use Add on snap IK to FK)

    I actually needed to add Thigh.IK.tws(R / L) as same as Shin.IK.tws(R / L). so now I can locate Thigh and Shin IK (tws) bones (tws) to the FK leg Thigh and Shin.

    I do not see any mesh change any more. with mix use Shin or Thigh twist for each mode.

    Though I do not know if Thomas actually need to add new twist only bone for Thigh.IK.tws only for snap things.

    (basically we adjust IK Thigh Y rotation by pole, >> auto set Shin Y rotation >> then use Shin twist bone for customize (or it is used only for snap IK <> FK)

    Once customize rig so (add twist only IK bones for Thigh and Shin) , I need to edit snap FK to IK, I need to locate Thing.FK to Thigh.IK.tws (R / L), >> Shin.FK to Shin.IK.tws(R / L) >> foot.FK bones to foot IK bones. (because add on simply ignore those new added twist )

    The snap relation change like this

    shin.FK <> shin.IK.tws , Thigh.FK <> Thigh.IK.tws then we need not use Shin.IK and Thigh.IK for snapping bone. because those are auto decided, when add on set pole target , and each bone location.

    Compare these 2 pic please without new twist bone.

    1_ pose with FK and add twist for left Thigh and Shin as I need.

    2_ use “snap IK to FK”. then change IK props 1 to 0. I clear see, shin twist with IK influence (cause deform for shin area)

    It is issue, when we add on snap IK to FK for shin, thigh twist FK pose.

    Then I run my custom script , it only adjust IK bones (IK tws bones rotation) for FK leg bones. so it only effect for IK posing

    now I can not see any deform with IK influence change. = perfect snap for IK to FK and get same mesh deform. (= deform bones locate perfect same place)

    import bpy
    import mathutils
    
    pbs = bpy.context.active_object.pose.bones
    amt = bpy.context.active_object
    
    st_ik_l = pbs["shin.ik.tws.L"]
    s_fk_l = pbs["shin.fk.L"]
    th_fk_l = pbs["thigh.fk.L"]
    tht_ik_l = pbs["thigh.ik.tws.L"]
    
    def snap(src, trg):
        src.matrix = trg.matrix    
        bpy.context.view_layer.update()
    
    # after generate 2 new twist IK leg bones for Thigh and Shin, 
    # use snap IK to FK, afer that run this scirpt adjust IK to perfect fit FK leg)
    
    snap(st_ik_l, s_fk_l)
    snap(tht_ik_l, th_fk_l)
    

    Then if Thomas need real blend scene which I add 2 tws bones for IK chain, and change constriains, I may add blend file. or anytime ask about it please if you do not clear what I did. About FK to IK snap, I need to customize your add on script to set Thigh and Shin first then not test still but basically it should work . (you only need to change target bone to snap FK bone)

  3. engetudouiti reporter

    I confirm it work (for IK to FK snap) almost perfect, so I attached blend file which only include G3 mesh and MHX rig, without texture and materials.

    So pose with FK, use FK shin and Thigh twist , and test how it work. (1st just use add on snap IK to FK, then change IK influence, next use script (run) with select rig.

    The rig already added new IK twist bones with shape , and set bone layer as IK foot chain.

    As usuall I only add those for left side IK chain. (because it is same as right leg)

    I suppose same way can use for IK arm chain. but anyway at firrst Thomas check it please. (If you have find another issue or not).

  4. engetudouiti reporter
    G3 mesh + new IK 2 twist bone (for left leg Thing and shin ) already set constrain correctly.  + test script to adjust IK bone to fit FK legs
    
  5. Thomas Larsson repo owner

    Yes, this is good idea. Implemented in last commits (import_daz + mhx_rts). I added twist bones not only to the shins but also to thighs, upper arms and forearms, because there were problems with snapping them, although not as obvious as for the shins. Now I think that snapping is almost perfect in both directions. The only problem that remains is the forearms, where the twist is already determined by the hand rotation.

  6. Thomas Larsson repo owner

    The twist bones are located on the two extra layers. You probably don’t need to access them very often, but perhaps you want to clear their rotations.

  7. engetudouiti reporter

    I thought you may need to make tws for thigh too to make things simple. Then I like the way to twist Thigh and Shin and deform well for IK pose. (I may often use it for usual IK pose even though I do not swap to FK mode)

    Then about hand rotation >> change forarm twist, I can not choose which is better.

    Actually I suspected when you returned hand rotate auto forarms twist will effect for snap issue. Then to make snap work perfect I supposed you may better not use it (or you may need more complex things) but maybe other user not hope to change current way so I do not request it.

    Anyway, I thanks you understand what I means correctly and offer really stable IK FK snapping for MHX with keep many function which MHX have offered. 🙂

  8. Log in to comment