Remake rig generate script if you can

Issue #138 resolved
engetudouiti created an issue

I know current plug in is already offer stable rig. (at least about default import rig)

But at same time, there still remain only one problem then hope Thomas take time re-write

script which generate rig as same as daz way.

The problem is

  1. Thomas use bone “end position” of data, to set each bone “tip position” in blender. But actually it not used in daz. The bone end points is used to locate rig with hand. but the real (visual) end points is set by bone orientation values and axis order. bone end points only decide the length of the bone. so if the figure bone visual end point not same as data end points which discribed in duf (or json etc), it may locate bone tip differently. we need to get visual end points not data end points (which not used to set bone tip)

take look this daz product bat figure, you may see, bone end point (the arrow) is not locate, bone tips. at all.

But current DAZ importer pick the value, then locate bone tip in blender. then it generate Bat rig, like that.

Why at current, problem is not so clear,, most of daz default figure locate bone tips near the data end points. (but slightly different). So when generate rig in blender,, the rig bone tip slighty different from where it actually locate as visual in daz studio.

If you import genersis3 and check pectoral bone, you may see clear,, actually bone end position is not same as daz studio.. (because G3 pectoral bone end position not locate as same as data end points.

2. I can see bone roll in blender not perfectly same in daz studio. I can say almost same. but if we generate bone correctly with data, it must be same. only difference is direction of bone axis, (X Y Z) , because there is special “rotaiton order” which we can not in blender for negative direction or we need to flip bone. but, the axis direction angle should be same.

And we can generate and locate bone as same as daz way. (some bone need to change axis rotation order, for the “flip case”.) with use values which already generated as JSON (dbz)

Because I could make script, only for the purpose, but I recently find, if I use my script, and re-generate rigs, it may cause problem when import Pose controller. Because at least about “pose controller”, it depend bone roll in blender. so If my script change bone roll, it cuase wrong rotation for bone with imported pose controller.

I think if Thomas can take time to check my script, you know how to clear. so plug in can generate perfect same rig as daz rig, in blender for default rig.

Though I know, most of case even though bone tip is slightly different from what we see in daz, it not cause many problem. But I think to generate almost perfect same rig is important, to enhance meta-rig and convert to rig-fy or another rigs. (because default rig is start point to convert rig)

Comments (8)

  1. Thomas Larsson repo owner

    It seems that I had misunderstood bone orientation in DS. I thought that a bone was just a node that could be oriented arbitrarily, independent of the bone direction. Assuming that, I couldn’t understand how you could orient the bone corretly in Blender by just flipping axes. But apparently a bone is always oriented along the X axis.

    In the last commit I introduced two new import options temporarily:

    Daz Bones: the tail is along the X axis if selected, otherwise use the end_point.

    Daz Orientation: roll matches DS orientation if selected, otherwise use the old way to compute the roll angle. This code was already present but it was written so long ago that I had forgotten about it.

    I think it is rather safe to use Daz Bones. I’m unsure if the computed roll angles are correct, and in any case some of them differ significantly from the other method. MHX and Rigify will not work with these roll angles, but perhaps they are calculated right.

  2. engetudouiti reporter

    At first I really apreciate and thanks , you know there is a little problem about the current way to generate rig and take time to consider again.

    I think I can tell all step how daz generate rig and locate bones in daz rigging tool, with daz end points, center points, each orientation, along with bone pose “Eular rotation”

    I do not know why daz do not use “end points” as real bone tip location, but I assume the end points is only used to locate bone when we start rig in DS without any orientaion. DS generate bone along to world axis which represent 1st pose rotation axis, when start rigging in daz studio rig mode.

    if daz bone rotation order = XYZ, XZY

    daz rig tool locate bone end points along to world X axis. without any orientation the bone end points is bone tip postion. at same time bone local Y axis, Z axis along to world Y and Z

    So daz use bone end points, set start position of each bone to make rig.

    then we orientate bone along to world X axis, with X orientation value.

    next we orientate bone along to world Y axis with Y orientaiton value.

    finally we orientate bone along to world Z axis with Z orientation value.

    bone locate as rest pose postion.

    of couse we may use center pints, to transform , but it can be circulated easy.

    (though we may start transform center point first when we rigging, but it not matter to represent as script. we can add transfrom later)

    The complex thing is, I had believed I need to orientate bone with pose rotation order, but it not.. if we use matrix, we need to keep the orientation oder for bone orientation as world X, Y, Z order.

    rotX >> rotY >> rotZ. it is not matter which pose rotation order is used for the bone. to generate and locate bone, daz use world XYZ rotation for bone orientation to set up rig.

    Then what I did was, just re-generate bone as same as daz way in blender. But there is a clear difference.

    In blender, we can choose pose rotation order as same as DS, but when we generate one bone , without any roll, and any pose, the bone tip alwasy along to blender world Z axis. so I need to adjust it with blender tool.

    after generate no orientation bone, in edit mode, I orientate pose bone, in pose mode , to get same visual direction as DS.

    if DS bone rotation = XYZ, I need to rotate bone along Y axis 90 . so now it show same tip direction (blender X axis). if bone rotation XZY, I need to twist bone. 90 (or -90) degree too.

    After locate bone as same as daz way, I can use daz orientation value, to decide final rest pose . It means rotate bone, along to world axis X>Y>Z with each orientation values (in blender, X>Z>Y order, after that, Apply pose as Rest pose. then finally use bone center points value to transfrom edit bone.

    Then I still find, there is case, bone direction is not good for blender armature, but about all case, I only need to add roll +90 , -90, or +(-)180

    Blender can not show perfectly same bone local axis, because blender twist axis is always bone local Y direction. but daz can choose all Eular rotation.

    So I need to adjust it with compare daz rig with each daz bone rotation order. and filipped bone,,, even though I use same scirpt, there seems case, I still need add roll 90 to show same axis visual direction as plug in default rig.,,but it can be improved by make bone template (which bone may need to add 90, or add 180), and it can offer more precise bone roll. (bone local axis)

    Because about daz pose controller, (it need to use bone rocal axis to rotate bone with driver), actuall bone end points, and bone roll is important. if bone end points is different from daz, the rotation axis already changed (slightly or sometimes it show heavy difference)

  3. engetudouiti reporter

    I hope Thomas still see this topic. I know this request need more time to work ideal. And need to check many things. So basically I hope you enhance gradually and keep it as user option.

    Then after I test new? 2 options, I still see difference what I expected.

    See those 2 pic please.

    One is I import character with activate new 2 options (daz roll, and generate same rig)

    I think it enhance (it seems more correct than before), but I still find difference about bone roll and end points. It seems happen only about some bone or it seems more clear about some bones.

    picA

    pic B

    I believe You understand Pic B seems locate pectoral bone same as daz rig.

    Though you may feel bone axis need to add roll 90 multiple to work best in blender,

    but bone roll direction of pectoral X and Z axis is not diagonaly direction, almosto horizon and vertical.

    About Pic A, you may see, bone tip sligtly locate up-wards of mesh. then bone X and Z axis toward diagonal direction.

    Pic A and Pic B actually use same data, which generated as dbz file (by your script)

    but Pic B is my customize script generated. Pic A is which current plug in generate with use new options.

    It is interesting because DAZ official plug in actually show almost same issue.

    (though I do not expect, they can manage this problem l, they do not consider such detail)

    And DAZ official importer do not keep bone driver, but just import defomation as shape keys so it not need to consider, how breast bone roll changed.

    (so when sholder bones rotate, they do not rotate pectoral but generate new shape keys, for defomation. it is not ideal way. (shape keys can not show smooth curve with rotaion,, it work as linear)

  4. engetudouiti reporter

    And same thing happen about Shin bones. (actually most of bones may slightly change if I compare, my script customize and default add on rig)

    I can clear see difference when I exchange 2 rigs by scripts (I made 2 buttons, to restore and customize functions)

    You may see my character foot sligtly toward outerward, but plug in generate Shin bones axis along to blender gloval Y axis.

    Then If I check Shin bone axis direction (Daz show as color plate in bone), actually it slightly toward out side ( the Z axis in these pic)

    It may more clear when I activate rotation gizmo for blender, and daz with local axis for posing.

    this pic is current add on generate bone roll. as you know the roll direction to bend axis is not same as daz.

    then after I add my script to adjust roll

    I think you feel this one show more correct roll axis to bend shin for this character.

  5. engetudouiti reporter

    I think this issue priority is low. (though it is important), and I found another problem when Bones already posed by ERC morphs or user posed then export. (for foot pose, or for breast adjustment morph etc)

    I almost confrim there should be more perfect way, to get roll and generate bone correctly, but need more time.

    (my way is at first generate all bones from Thomas rig, then they can easy pose without defrom mesh, after that I can copy and paste, my adjust ment for each bones to original bones, then delete my added bones, so I can rotate, tarnsform free without deform meshes)

  6. engetudouiti reporter

    Thomas test please, 😉 when you can find time.

    this is recent version which correct added pose rotation quartanion ( or Matrix)

    My old versions did not circulate quarternion for posed rotation correctly . when boens already posed in daz stadio (by ERC morph and by manuall )

    I test with simple donner bones, and my old scenes, Now it can show perfectly same tip postion, and almost same axis angle I think.

    The usage is,, after import daz scene,

    1 select all rigs and import same dbz file, by “import json”

    2 click adjust rig. now it adjust all rig bones (currently selected), as same as daz rig.

    I suppose it is not matter how user set Eular rotation in blender.. (I usually only use YZX rotation order,,for blender armature)

    Though there still remain same problem,, when import pose controller, and driven bone ,because they need to keep default add on generated local axis. I understand reason, to import duf morphs or drivers, it change each axis (Eular) rotation value.. so if we change axis , it show different effect.

  7. engetudouiti reporter

    Finally new option show same rig as my script ^^;

    for pectoral etc etc,,, so now it represent same roll as daz (thanks you!) as one option..

    I think, it is good start point,, (add bone table we need,,for specific bone, and I know some case,, it may show different bone transform I may report each case,

    I know about some case,, I need to freeze rig in daz studio,, when vendor offer rig without “memorize rig” but manually set for current pose,,

  8. Log in to comment