Y rotation of of ShldrBend and ThighBend bones cannot be locked (restricted to 0) in IK

Issue #866 resolved
fume knight created an issue

first ,this has nothing to do with the addon ,this is blender own limitation

when using IK ,the last bone in the chain can never get locked on the Y axis , you can try it for yourself

pose the ik handler and apply the visual transformation

the problem is the ShldrBend and ThighBend bones aren’t supposed to rotate on the Y axis ,since that’s the job of the twist bones

I fixed the problem using rotation copy constraint

I duplicated the the bones needed for the ik chain, in this case, made a copy of, upper arm bendupper arm twistforearm bendforearm twist, fixed their hierarchy, created the ik chain from the copied bones, made forearm bend and forearm twist copy the rotation each from its own duplicate, made the upper arm bend copy only the X and Z of its duplicate and finally, made the upper arm twist copy the rotation from its duplicate and the Y rotation of upper arm bend

i’m an idiot so i don’t know if there is a simpler solution ,already asked at

https://blender.stackexchange.com/questions/252198/how-can-i-limit-the-rotation-of-a-bone-using-euler-angles-in-ik

it would be nice if this problem is taken into consideration when making the simple IK

Comments (26)

  1. Thomas Larsson repo owner

    Simple IK has its limitations. For serious animation in Blender I would use MHX or Rigify, which don’t have this problem since the IK chains consist of two bones only, even if there are four deform bones. Or you could pose with simple IK, snap to FK, and tweak the FK pose. That could be useful if you want to export the pose back to Daz as a pose preset.

  2. Alessandro Padovani

    Fume, you can also use the poles then counter-rotate with the twist bones. That makes sense in a ik contest and exports fine to daz.

    Thomas, there’s a issue with simple ik when saving the pose preset. It seems “bake pose to fk rig“ doesn’t work with simple ik, so we always need to snap fk bones. Please let us know if this is an intended limitation.

    daz studio 4.15.0.30, blender 3.0.1, diffeomorphic 1.6.1.0860

    steps (this doesn’t work):

    1. import g8f, merge rigs, make all bone posable, add custom shapes, add simple ik
    2. go to pose mode and pose some ik
    3. “bake pose to fk rig”, this will lose the ik pose and won’t bake to fk
    4. save pose preset

    steps (this works):

    1. import g8f, merge rigs, make all bone posable, add custom shapes, add simple ik
    2. go to pose mode and pose some ik
    3. snap fk to ik
    4. save pose preset

  3. fume knight reporter

    @Thomas Larsson

    first i had like to say i tested MHX or Rigify ,both suffer the same problem

    to check ,just pose the leg using ik ,then apply visual transform to pose

    for MHX ,check the thigh.bend.L bone ,it always have Y rotation

    the bone thigh.bend.twk.L associated with the vertex group thigh.bend.twk.L is the child of the bone thigh.bend.L

    also MHX and Rigify are are out of the question since the rotation mode of the bones are all over the place

    anyway ,this is not about simple IK ,like i said this is blender own limitation

    with IK in blender ,you can NEVER restrict the Y rotation of the last bone in the ik chain using euler angles

    it’s possible using quaternion but not euler angles

    as unless the ik setup composed of two bones is made in a way that the FK bend bone only copy the X and Z and the twist bone only copy the Y ,it will never work

    actually thank you ,i knew i was an idiot ,instead of using a four bone ik chain for the arms and a three bone ik chain for the legs i can i simply use a two bone ik chain ,then have the bend bone copy the X and Z and the twist bone copy the Y

    you should consider using that as well

    thanks once again for this great addon

    also is it possible to import a g8.1f using the skin of g8f and eyes of g8.1f with only one UV ?

  4. fume knight reporter

    @Alessandro Padovani

    that’s pointless if you are doing an animation ,since that only work for one pose

  5. Alessandro Padovani

    What do you mean ? I can’t see why, you can keyframe both ik and fk bones, just tested and works fine in animation. Then if you mean that “bake pose to fk rig“ doesn’t work that’s reported.

  6. fume knight reporter

    @Alessandro Padovani

    try it again ,but this time bake the animation and check the frames in-between

    it is possible yes, but only for one frame

    the nature of ik make it seek the shortest route as a WHOLE ,so unless you fix the Y rotation every single frame ,no it won’t work

  7. Alessandro Padovani

    If you mean that you want the bend bones to never twist then yes you’re right. But this is not necessary. You can always counter-rotate with the twist bones to reach the desired twist of the thigh geometry. Then in daz studio you have to turn off limits when importing the pose. It is not uncommon to turn off limits for daz poses.

    Unless I miss to understand what you’re after and why.

  8. Thomas Larsson repo owner

    Rigify does what is does, and I cannot change that. As for mhx, I notice that the bend bones have a damped track constraint. I tried with copy rotation local X and Z long ago, but never managed to get it to work properly. Damped track is much more stable.

  9. Alessandro Padovani

    Fume, please can you explain step by step how do you change the simple and mhx rigs so we can test it ? I mean if it works and it’s an improvement then it’s nice to have. Personally I am dumb about rigs so need a good explanation, may be with pictures.

  10. fume knight reporter

    @Thomas Larsson

    @Alessandro Padovani

    that’s way i did not mention MHX until you did ,the MHX is simply too complicated ,modifying one thing can ruin everything ,not to mention the rotation mode is all over the place

    simply fixing your own simple IK is much better to be honest

    just create a two bone ik chain for each limb ,bone 1 and bone 2 ,merge the inverse kinematic constraint values

    for thighs ,shoulder ,have the bend bones copy the X and Z and the twist bones copy the Y ,the shin bone copy everything ,and lastly ,the forearm ,the bend bone copy the X ,the twist bone copy the Y

    but this way the posing is painful hahaha so i gave up on it

    so do like i mentioned in the first post ,arm ik example

    I duplicated the the bones needed for the ik chain, in this case, made a copy of, upper arm bendupper arm twistforearm bendforearm twist, fixed their hierarchy, created the ik chain from the copied bones, made forearm bend and forearm twist copy the rotation each from its own duplicate ,don’t forget the rotation locks , made the upper arm bend copy only the X and Z of its duplicate and finally, made the upper arm twist copy the rotation from its duplicate and the Y rotation of upper arm bend

    since if i duplicate each bone and create an ik chain out of them and rename the bones in the pose duf file to those of the duplicate bone serving as ik ,i am even able to import poses with no trouble ,of course disable the ik before the import ,import the pose ,snap the handle ,then enable the ik

    for the ik stiffness ,i found no magical value that fit every situation ,the user should simply animate it as he needs

    ok ik aside ,there is a problem with the main rig

    the shoulder BEND bone ‘ShldrBend’ ,was never meant to rotate in YZX ,it should be in XYZ

    as it is ,this create two problems

    the bending is never right …. unless you rotate the twist bone ,then the bending is fixed

    the real problem is this : the jcm pJCMShldrFront_n110_Bend_p90 and pJCMShldrFront_n110_Bend_n40 never return a correct value because they were made to work only if the shoulder bone is rotating in XYZ and not YZX

    the rotation mode should be fixed in addition to updating the drivers of the shape keys pJCMShldrFront_n110_Bend_p90 and pJCMShldrFront_n110_Bend_n40

    i’m honestly not even sure how did you manage to copy poses from the duf files when some of the bones have the wrong rotation mode

    you can only get away with the wrong rotation mode if two axis are locked

  11. Thomas Larsson repo owner

    The rotation mode in DS is XYZ, but in Blender the axes are flipped because Y must always point along the bone. Therefore the rotation mode must be changed too. If you disable Z Up and enable Unflipped Bones in the global settings, the rig is imported with the same orientations as in DS. But that is not very user friendly.

  12. Alessandro Padovani

    Thomas, what about “bake pose to fk“ reported above is it a bug or an intended limitation ? Let us know please.

  13. Thomas Larsson repo owner

    Well, I had forgotten about the Bake Pose to FK tool. The tooltip says “Bake pose to the FK rig before saving pose preset. IK arms and legs must be baked separately.“.

    So this button is not for snapping the FK bones, but for other bones. E.g., in mhx there are bones that pose the entire spine, the neck-head, and all finger links. These bones do not exist in the daz rigs, so their poses would be lost if you reexport to DS.

    To bake the FK arms and legs, use the separate tools that exist both for mhx, rigify, and simple ik.

  14. Alessandro Padovani

    Thomas, for separate tools do you mean the “bake action“ tool in blender ? For mhx there’s “transfer ik to fk“ that’s not limited to arms and legs afaik. Then for rigify and simple-ik I can’t find any tool by the plugin. So I guess the workflow is intended as below ?

    steps for rigify and simple-ik:

    1. animate with ik
    2. bake to fk with the blender “bake action“ tool for arms and legs
    3. bake to fk with “bake pose to fk rig“
    4. save pose preset

    steps for mhx:

    1. animate with ik
    2. bake to fk with “transfer ik to fk“
    3. save pose preset

    edit. note. Since “save pose preset“ can’t work without baking because daz poses are fk, it would be nice and easy to have fk baked automatically by the tool, before saving. If this is possible and not hard to implement. Otherwise “save pose preset“ works only for fk animations with the daz rig.

  15. Alessandro Padovani

    Fume, it turns out I was proposing the same thing in #483 a long time ago. It didn’t end well so I guess Thomas may not follow here too.

  16. fume knight reporter

    @Alessandro Padovani

    @Alessandro Padovani

    i must be blind lol ,because last week i literally spent too much time and i never stumbled on your thread ,that could have saved me one day if i did lol

    anyway my rig work perfectly with copy rotation in YZX ,do exactly as i said in my previous answers and see for yourself

    i only created this thread because i thought nobody noticed the ik problem

    leaving that aside ,there is a bigger issue

    @Thomas Larsson

    @Thomas Larsson

    the shoulder problem is bigger than i thought ,even JCM for the shoulder up and forward aren’t always right and not only that

    below are two picture ,exactly the same pose ,one posed in blender and the other did the posing in daz

    first ,in daz ,i only moved the left shoulder bend -55 on the X( front-back tab) and 45 on the Z (Bend tab) ,to achieve that same pose in blender i had to move the bend bone 63.7 on the X , 39.3 on the Y , 23.9 on the Z , keep in mind the Y is supposed to be locked

    if the rotation mode is YZX ,the rotation limits are useless ,sure they serve their purpose if you only move on one axis ,but not if you combine them like in the pic ,and nope, moving the twist bone instead is not right ,this need to be done by the bend bone alone

    the second problem ,the JCM for the shoulder up and forward are wrong as seen in the pictures but it should be obvious why if you read the last two paragraphs

    leaving that aside ,could you tell me please how can i translate spline_tcb into a function in blender ? i need it to set some shape key drivers

  17. Thomas Larsson repo owner

    Now I see what you are saying. The plugin assigns YZX to most bones, but keeps a list of exceptions. The shoulder bones have been added to that list. Not very elegant, but since it really only matters for jcms (I think), the plugin can know about the genesis rigs.

  18. fume knight reporter

    @Thomas Larsson after i fixed the jcm and changed the shoulder bend rotation mode to XYZ ,the FK posing became perfect

    but now my setup for the IK was ruined ,more like any ik is impossible

    to fix that i changed the rotation mode again but this time to YXZ

    for the shoulder bone ,unlike YZX ,every possible combination of the two axis X and Z are the same for these two rotation mode XYZ and YXZ

    and while daz use XYZ ,in blender ,to have IK working properly with limits and jcm ,it's better to make the shoulder bend rotation mode YXZ

  19. Thomas Larsson repo owner

    OK, I changed the shoulder rotation mode to YXZ. It doesn’t matter for the jcms, since Y is locked anyway. But the drivers for the mhx rig are off, have to check why.

    For an example of a splineTCB driver, see the armature property pJCMThighFwd_57_L(fin).
    (1 if A< -0.995 else -1.005*A if A< 0 else 0)
    where A = lThighBend X rotation.

  20. Thomas Larsson repo owner

    The rotation modes have been corrected for MHX and Rigify as well, and now the jcms seem to have the right values.

  21. Thomas Larsson repo owner

    Now posing works for mhx and rigify again. The pose importer assumed that the rotation mode for the bend and twist bones was YZX, which isn’t true anymore after the last changes.

  22. fume knight reporter

    @Thomas Larsson

    first issue is not really that important

    but the Y rotation limit should be changed to max 80 min -95 for the left shoulder twist bone (right is fine)

    the Y rotation limit should be changed to max 90 min -80 for the right forearm twist bone (left is fine)

    now ,after downloading the latest version ,importing figure jcm abort in the middle because it fails to get this jcm pJCMNeckTwist_Reverse ,rest import fine if you don’t tick that specific jcm

    here is the error

    also ,shoulder up and forward jcm are working fine ,but pJCMShldrFront_n110_Bend_n40 and pJCMShldrFront_n110_Bend_p90 are not moving at all

    one last thing ,about the spline tcb , you misunderstood what i meant

    what i want to know is the actual equation for the curve please

  23. Thomas Larsson repo owner

    Most things fixed in last commits. I didn’t see the crash since I’m mostly working in Blender 3.0 and it only happened in 2.93 and before.

    To invert the limits, the plugin keeps an explicit table of special cases. There should be a general way to do this correctly without relying on exceptions, but this is simpler. Besides, it took a long time to figure out the algorithm for matching daz and Blender bones, and changing it now could have unforeseen consequences.

    I’m approximating the spine with a piecewise linear curve, which is the conditional expression above. Don’t know if DS uses something more complicated.

  24. Thomas Larsson repo owner

    The shapekeys with the long names move here. E.g.,

    lShldrBend = (40, 0, -20) => pJCMShldrFront_n110_Bend_n40_L = 0.182
    lShldrBend = (40, 0, 50) => pJCMShldrFront_n110_Bend_p90_L = 0.202
    rShldrBend = (40, 0, 20) => pJCMShldrFront_p110_Bend_p40_R = 0.182
    rShldrBend = (40, 0, -50) => pJCMShldrFront_p110_Bend_n90_R = 0.202

  25. fume knight reporter

    @Thomas Larsson well those values are perfect

    thank you for your hard work

    should i set the thread as solved ? the main problem is fixed after all

  26. Log in to comment