Import Hip bone transform pose can not import correctly (rigi-fy)

Issue #242 resolved
engetudouiti created an issue

So with recent up-date I concentrate rigi-fy pose (and import pose file) with this add on now.

Then un-fortunately, Rigi-fy actor still show clearly wrong transform about Blender Torso = Daz Hip bone.

It is G3 test file, then it only include “hip” bone Location and Rotation. About hip it is most usuall pose I think. I can clear see,

daz Hip bone and blender Torso (rig-fy) can not show same pivot. but it is not so heavy problem.. (and I can discribe how to manage)

But at start point, Hip transform (Daz studio) to Torso transform(Blender Rigi-fy) need to be converted correctly.

In blender.. (there is no need to select option, because it only include Hip bone transform, usually it need to show almost same pose with perfect same location value for Torso bone. (only rotation pivot will effect slightly)

Then I suppose the main problem seems,, at current about Torso FK bone,, it not count the bone local axis (and rotation order) when convert for daz hip bone.. (maybe just tried to use default imported rig HIP bone local axis, I suppose, but they are clear different..)

Though I suppose if, plug in once convert as world matirx then apply the transform for the torso bone, it may not happen..

(maybe conversion process is something wrong,, or it is simply bone axis problem of Torso bone and hip)

The FK torso bone is not follow , original hip as I sai,d it usually auto generated and locate pivot as rigi-fy way.

But it is only bone which can use for daz HIP transform conversion. (plug in now try to convert hip transform for rigify torso, and , it is correct )

Comments (18)

  1. engetudouiti reporter

    If it will be corrected, and user hope to see more precise rotation conversion for Hip to Torso(rigi-fy)

    We need to manuall edit, becaues HIp and rigi-fy torso pivot not show same position as default, it can not be adjusted by meta-rig.

    see this pic.

    (or it break other bone pivot which worked usually)

    fortunately I suppose even though we edit Torso bone pivot, it not cause issue. it can move free with edit mode, so it only decide full rig transform pivot (as center), then we can adjust it.

    (and there are already rigi-fy option which will generate user custom torso pivot , but it may not work at least for import pose, we do not know user use it or not, so if we simply convert pose of HIP, we need to use current torso. and user may try to edit torso pivot manually, to get same rotation pivot for daz Hip rotation.

  2. engetudouiti reporter

    Then I suppose plug in may use blender PoseBone “matrix_basis”

    to actually pose each bone,, as you know, matrix_basis, need to consider, parent bone local cordinate.

    Problem is,, for Rigi-fy “Torso” bone. (which you may need to apply matrix_basis circulated from daz Hip transform values)

    actuall parent bone is MCH_Torso.parent bone. for rigi-fy.

    So circulated matrix_basis (matrix) will be applied for the MCH_torso,parent bone local cordinate and pivot.

    The MHX_torso pivot and local cordinate is pefectly same as Torso bone, with rest pose.

    but it not same as “Root” bone pivot, and the bone local cordinate.. so I think if it cause issue.

  3. engetudouiti reporter

    Then I made 2 pose file to detect the problem. it could teach me what seems cause issue.😃

    So when I import Hip location only, (no rotation), it can show pose correctly (the location delta applied for torso)

    about location , matrix pivot location have no meanig.

    but when I import Hip rotation only, (no location delta), it can not show pose correctly.

    I can clear see, now rotation pivot change. ( when script apply pose matrix use different center)

    when import and apply matrix value, it ignore my current rotation mode for the bone, and pose setting, so my setting may not effect when apply pose by script I believe. The only problem is transform matrix center which used for Torso bone pose.

  4. engetudouiti reporter

    And it is not only about pivot location issue.

    because if I save 3 rotaiton mix pose for hip, then import with add on, it not show same direction. (even though I remove transform, from current import pose, hip rotation (rig-fy toso rotation) not show rotation same as daz with use Front view . (use HipRotAll.duf I attached)

  5. engetudouiti reporter

    There are 3 matrix when apply them for pose bone in blender,

    I have not many experience about import pose. but I wan to know, Thomas use which matrix to apply pose?

    I have custom script, which can generate matrix for each bone. so I can check easy current pose matrix, matrix_basis, or matrix_channel

    I may hope to get, converted matrix, which generated from daz hip bone pose value , with your script, (then it will be applied for torso bone)

    and compare them with current posing (make manually in blender to show same pose in daz) bone matrix. (toso)

    it may tell me clear difference, and may be I can get pivot or other rotation value changed form them.

    For me, other bone rotation seems work without problem, (I do not expect perfect same pose,, but basically they show reasonable bone rotation for rig-fy FK bones, already, only need to check some bone lock options, or it break sometimes)

    At crreunt, Only about hip, it seems not apply the rotation correctly for rigi-fy. recent version already correct pose which only include location for HIP, so it may work better with mix other pose rotation when import daz pose file. (some vendor not apply rotation for Hip bone only use location. then use other bone to get same pose, so it already improved, then now hope to get hip rotation .

  6. engetudouiti reporter

    eg,,,

    1. I save preset with rotate Hip bone, in Z 45 ,
    2. .I make same pose in blender with Torso. then generate matrix (or matrix_basis) as readable data. at current I only make my script to generate bone transform as matrix_basis, then improt it again. to save pose. (only need to change matrix_type for test)

    {
    "type": "pose_preset",
    "figure": "Genesis 3 Female",
    "pose": {
    "torso": [
    [
    0.7071067690849304,
    -0.7071068286895752,
    0.0,
    0.0
    ],
    [
    0.7071068286895752,
    0.7071067690849304,
    0.0,
    0.0
    ],
    [
    0.0,
    0.0,
    1.0,
    0.0
    ],
    [
    0.0,
    0.0,
    0.0,
    1.0
    ]
    ]
    }
    }

    I will compare your converted matrix or matrix_basis, untill applyi it for pose. Mabe it show clear difference. when format as blender matrix. which show current matrix pivot location. if you have option, to print matrix (after convert) in console.when import pose for rigi-fy. I only need to test with Hip converted matrix.

  7. engetudouiti reporter

    1.set pose in daz studio for hip rotation as (x30, y45, z120) (hip rot = YZX)

    2. represent in blender to get same pose. (as x30, y-120, z45) with ZYX Eular. it show perfect same pose.

    3. generate current torso bone as Matrix.

            "torso": [
                [
                    -0.3535536527633667,
                    0.35355350375175476,
                    0.8660252690315247,
                    -2.150149839508231e-06
                ],
                [
                    0.9185584783554077,
                    0.3061866760253906,
                    0.2500000298023224,
                    -0.014835026115179062
                ],
                [
                    -0.17677700519561768,
                    0.8838832974433899,
                    -0.433012992143631,
                    0.909407377243042
                ],
                [
                    0.0,
                    0.0,
                    0.0,
                    1.0
                ]
            ]
    

    torso bone lcoation = (0, -0.0148, 0.9094)

    reset pose, then import saved duf daz pose file with plug in, (now it show different pose), generate matrix fpr torso bone

            "torso": [
                [
                    -0.3535533845424652,
                    0.7391988635063171,
                    0.5732232928276062,
                    0.5103282332420349
                ],
                [
                    0.7071067690849304,
                    0.6123723983764648,
                    -0.35355332493782043,
                    -0.33061009645462036
                ],
                [
                    -0.6123723387718201,
                    0.280330091714859,
                    -0.7391989231109619,
                    -0.6763904094696045
                ],
                [
                    0.0,
                    0.0,
                    0.0,
                    1.0
                ]
            ]
    

    torso bone location (object space) change as (0.51 -0.3306, -0.676)

  8. engetudouiti reporter

    After consider daz hip pose (rotation, transform)

    actually it seems simple thing for me. if you use posebone.rotation_euler. then just set axis order as same as daz (convert blender world)

    that means, after all we get hip Euler rotation value. from pose duf. as float tuple. eul = (xrot, yrot, zrot) , and hip rot order is always YZX

    even though it change with rig, we know, the rot-order already stored as custom prop of bone. so you can keep use it.

    when import pose. then if use the Euler rotation for blender rig-fy torso, we only need to change rotation order as (ZYX) but set Y rot multiple -1.

    I believe you can easy set blender Euler rotation order, from bone daz rotation order with function. etc. I suppose you already made it and use it.

    Then actually we can make almost perfect same hip rotation, manually, just keep the way I menitoned. (set rotation mode, and input values)so we just need to do same-thing by bpy.

    blender pose mode already offer way to set current pose as posebone.rotation_euler

    it can read and can set. as float tuple (rotx, roty, rotz) then posebone actually rotate with these 3 values. to use it correctly, we only need to set rotation_mode first.

    As you know, rigfy default torso pose mode = “QUARTANION” but it not matter. you can temporally keep current pose mode,, r_mode = pb.rotation_mode

    then change current pb.rotation_mode = ‘ZYX’ then convert daz eul(xrot, yrot. zrot) to blender eul

    it syould be, b_eul=(xrot, -zrot, yrot) (it is not matter what rotation order is used for daz, and in blender, Though we need to covnert daz rot value as radian, after that, set the b_eul for torso bone)

    posebone.rotation_euler = b_uel

    actually it is all code which we need to apply hip bone rotation for rig-fy torso. I can confirm it work, with rotate other bones as I like (include root etc,, for torso bone rotatiion, it is all, we need not to think about current matrix pivot etc,,)

    Then we need to set pose location of torso bone finally.

    I think simply use posebone.rotation_euler is actually easy enough at least to set rotation for torso from daz hip.

    if use matrix of blender cause issue only for hip rotation convert for rig-fy, I may recommend, use rotatin_euler . then return rotation mode for user which they had used for the torso pose bone…

    ===
    Then at least for rigi-fy converted rig, we do not suppose import pose for user hand made converted rigi-fy rig. that means we only need to consider genesis family. plug in only convert them. then all genesis generation hip use same rot order = ‘YZX’, to converted rigi-fy torso

    rot order can set as 'ZYX' there is no exceptional case for torso bone. (after all we return it as “Quartanion”, set order is only used to set rotation_euler for rigi-fy torso temporally. we do not need to think-about other case.

    To represet daz genesis hip rotation, anyway set rotation_mode as “YZX” for the conversion target bone, then convert daz euler values, for blender world, set values as tuple. it seems most stable way.

  9. engetudouiti reporter

    import bpy
    from mathutils import *; from math import *
    
    pb = bpy.context.active_pose_bone
    mode = pb.rotation_mode
    
    def get_bl_eul(x, y, z):
        eul = (x/180*pi, -z/180*pi, y/180*pi)
        return eul
    
    def get_bl_loc(x, y, z):
        loc = Vector((x/100, -z/100, y/100))
        return loc
    
    def set_pose(rotx, roty, rotz, locx =0, locy=0, locz=0):
        eul = get_bl_eul(rotx, roty, rotz)
        loc = get_bl_loc(locx,locy,locz)
        pb.rotation_mode = 'ZYX'
        pb.rotation_euler = eul
        pb.location = loc
        pb.rotation_mode = mode
    
    set_pose(60, -45, -120, 50, -10, 100)
    # you can input daz hip rotation value, and location value in duf or daz UI
    

    script which I input values and confrimed it work. (need not think about any other bone.. it should show same rotation and location as local)

    1_ in daz studio, make pose with parameter for hip bone. (save pose file if you need, then check parameter values which saved with txt editor)

    2_ in blender, select torso bone

    3_ change set_pose() arguments, as which you set in daz studio. (lotation x, y, z, and lcoation x, y, z) run script

  10. Thomas Larsson repo owner

    This is essentially the same problem as #235. The bone and posebone properties needed to pose correctly were not copied to Rigify. Should work with latest commit, but you need to recreate the Rigify rig to pick up all bone properties.

  11. engetudouiti reporter

    I see…. OK I do not mind,, but do I need to re-export from json? or I can import same scene duf (with json)?

    Then if you can go father, I hope to get same pivot of torso as hip in daz for rigi-fy when convert-rigi fy.

    I suppose we can pick the bone center from rigi-fy hip bone. (it work as daz plevis bone) then adjust torso edit bone position

    (I do not think we need to edit MCH torso parent bone, but it may not cause issue even though , adjust torso and MCH torso parent bones

    at same time to keep bone arange ment of rigi-fy.

    (it can not be adjusted with meta-rig because rigi-fy seems use center of the meta rig bone as pivot , so it need user manuall or script try to adjust when convert meta-rig to rigi-fy. If you could take time I apreciate (so it show same pivot for rotation as daz)

  12. engetudouiti reporter

    Ah OK it is no problem. thanks^^ I may test again then will mark it as solved.

    then if you can check and consider #241 please , so about these case,, hope to save current meta-rig with my setting as blend file.

  13. Log in to comment