About new rig import option (default)

Issue #174 resolved
engetudouiti created an issue

So I only report about this issue. which may need to be solved untill “Default import option”

When the rig already pose in daz studio, (eg like foot pose etc)

Old import way can bake those rotation as rest pose. But current import option can not bake posed rotation value but keep edit bones as same as non zero pose. only center point may move with daz scene, which each rig posed then children bone may move .

simple test.

  1. use default option, to import. (in gloval setting tab)
  2. make scene which apply foot pose preset for figure. in daz studio.

import it with add on default option.

  1. visible rig in view port .
  2. bone not fit current mesh (mesh already deform as foot pose, then it is uspposed to rest pose mesh about the character)

So I could see, neither manuall pose rotation nor ERC controller rotation for bones applied as rest pose. (but center points = Head postion of bones move )

And edit-bones rotation keep non zero pose. that means,, orientation are correctly applied, but current pose rotation (ERC and manuall) not applied to set rest-bone correctly.

Old version did not show this issue, so I think it need to be solved, or we can not use it as default option (untill release stable version)

(Btw as my opinion, I believe new option really enhace import default rig as true meaning, so I really hope it work better than before about all case which have worked)

Comments (13)

  1. Thomas Larsson repo owner

    The problem is that the posed center and end points can be found, either using Daz script or by looking in the “preview” field in the duf file, but the orientation only seems to be available in rest pose. I recently added an orientation field to the dzb file, using the DzNode.getOrientation() method, but it didn’t provide any new info. This makes sense, of course. The duf files contain info that DS needs, and the orientation of a bone after posing is not among those.

    But usually you don’t want to import a posed character with dbz/json fitting, since the pose becomes the new rest pose. Unless you want to import it as a statue for rendering, and then the armature does not matter. The common exception is if the character is wearing some clothes that alter the rest pose, such as high heels. That case can often be handled when you merge rigs, as I wrote in this morning’s blog post.

    Having said that, I agree that the weird orientation of posed bones is confusing. I also don’t like that the Apply Rest Pose and Copy Bones buttons had to be brought back. They were there in version 1.1, when the plugin used Collada or FBX to transfer the rig and similar problems arose, and I was happy that they became unnecessary with Json/DBZ fitting.

    If this is too confusing, maybe it is better to go back to the old way, using the end-point as the bone tail. Both methods will remain, of course, it is only a matter of which should be the default.

  2. engetudouiti reporter

    Why I believe you can get and add posed rotation value from dbz, actually my script can do it from same dbz file.

    Then it is no matter which version daz importer I used.

    1 My script use getOrientation() to set bone orientation (generate rig of zero pose)

    after that, To get only posed rotation value (not rig orientation value for rest pose) you only need to pick "ws_rot" of each bone which generated by your script.

    the rot value are generated by bone.getWSRot() as quartanion.

    I remember when I asked about it, you said you do not use the value anymore, but use bone.getWSTransform()

    I tried your way, when I made my script, but it not worked for me,, then I simply use the “rot” value, which you have not been used (but remain it with my request)

    So please try to get only posed rotation value (include ERC pose controller added value) by bone.getWsRot()

    Actually it is reason why I need to re-import json (or dbz) to correct bone roll,,

    your scirpt not use the getWSRot() to set bone. then not remain tthe value as bone property.

    but I use it to add posed rotation value, after, use orientaiotn value.

    If you can not believe me,, please, test my script.

    My script pick “rot” value from exported json (by your script), then add it as new prop for generated bone.

    After that I use the value, to add posed rotaiton value.

    When I made my script, I did not make rig table.. but it actually set bone correctly,, and it still work with current import option.

    that means, the “rot” value which generated by getWSRot() actually show bone posed rotation value correctly. (not include bone orientaiton value)

    About scale, and transform , your script already work. so I just use same value (get from current bone head and tip position), but I only use the “rot” value. to add rotation which posed.

    “ orientate bone “ is already same as you. (though I can not check how you generate orientaiton,, but actually current your add on show same roll which my sciript did .. when I use it for non pose figure.

    And I clear remember,, current status is, when I first try to adjust rig by script. As same as you, I only used orientation value.. which generated by bone.getOrientation() .

    Then I felt happy, but after I foot pose for figure, then import and generate rig,, I see same issue. (posed value not applied)

    Then I read daz script document, and check your script, and confirm the getWSRot() value show how bone rotate with pose from rest pose. your script already generate “rot”.. so it is not difficult,, just add the value for edit bone, from current generate rig.

    anyway please use this formula

    pr is rot values (quartanion) which recorded in json, as "ws_rot"

    like "ws_rot" = [0,0,0,1] (in json)

    dq = (pr[3], -pr[0], pr[2], -pr[1])

    it change daz quartanion to blender world quartanion.

    dquat = Quaternion(dq)
    bp_mat = dquat.to_matrix()
    mat_pr = bp_mat.to_4x4()

    these are just convert quartanion as blender matrix.

    the last mat_pr is matrix, which we need to add after orienatate bone. I believe you only need it, to rotate edit bone, from current orientate bone (rest pose)

    or enb = each edit bone then,

    mat_o = ebn.matrix //get current edit bone matrix which you orientated, so we need to multiple matrix to rotate edit boens.

    ebn.matrix = mat_pr @ mat_o

    it is all step,,,

  3. engetudouiti reporter

    I may re-make my script,, just correct posed (manuall and pose controller changed) from current generate rig.. (your add on already show perfect orientation with rig-table,,)

    But to make it I still need to re-import dbz (json) and use the ws_rot value ^^;

    So I asked it you before,, (add ws_rot as each bone props,, then I can get hose value,, that means I need not re-import json again…

  4. engetudouiti reporter

    And why I like to see posed figure as rest pose in blender, actually some shape morph often pose rig with ERC…

    About those morphs we did not think, it posed figure,, as same as when we generate actor with foot wear.

    (daz studio may auto apply pose),

    I know, if we use posed figure as rest pose,, it already change local axis which used in daz studio,, so I usually try to export zero pose figure.. (so I need to adjust foot pose when I need,, but not bake it)

    But about some ERC morphs , I can not check them all in daz studio,,, vendor not concern, it is shape or pose.. they offer them as shape morphs ^^; so even though I seldom import posed figure,, I hope to remain the usablilty.. as same as before.. (with new up-date about roll and bone real end points)

  5. engetudouiti reporter

    Then I finally could see same status which only change foot wear as posed,, but keep actor rig non zero pose.

    So your discribed procedure may work for the case.

    But unfortunatelly it can not adapt all foot wear. Because when I use other foot wear,, foot wear and actor keep non zero pose rotation for zero pose.

    so I can not copy rig from foot wear. (there is no means,,because both show wrong)

    That is because each vendor may make individual morph or pose controller as their way.(not say detail,,)

    But as I said,, about both case,, same procedure work.

    we only need to get ws_rot value and apply it for each rig (actor and foot wear),, maybe about this foot wear,, ws_rot keep zero pose value as quartanion. (1, 0, 0, 0) etc

    Then I could confirm ,, foot wear ws_rot is almost zero rotaiton, only actor ws_rot change (in DBZ file), that means the ws_rot only contain posed value. (not include orientation )

    it is mika with foot wear,, I import.. I could see only foot wear rig fit currrent posed mesh. (it is what you discribed before)

    Then I apply my script,, (that means add ws_rot value to rotate current bones ,, as matrix)

    So we need not copy rig from foot.. but need ws_rot value (rotate edit bones, in edit mode with script)

  6. engetudouiti reporter

    I forget important thing. Untill you edit bone Matrix (add posed rotation) , I need to set bone location on world center, or bone transform another place.

    Now I make new class to add posed rotation, from ws_rot value. it include some funciton which not discribed as the class method,,(select rig or,, show info etc) but I believe you can easy understand,, how it work..

    class WIF_OT_adjustPoseRotation(bpy.types.Operator):
        bl_idname = "dazbone.addrot"
        bl_label = "text"
        bl_description = "add posed rotation"
        bl_options = {'UNDO'}
    
        def execute(self, context):
            bpy.ops.dazinfo.reflesh()
            objs = bpy.context.selected_objects
            if not objs:
                msg = "Select daz rigs first!!"
                showInfo(self, context, msg)
                return {'FINISHED'}
    
            for ob in objs:
                ob.select_set(False)
            for ob in objs:
                if ob.type == 'ARMATURE' and "DazRig" in ob.keys():
                    sel_act(context, ob)
                    amt = bpy.context.active_object
                    print(amt.name)
                    cmode = amt.mode
                    bpy.ops.object.mode_set(mode = 'EDIT')
                    ebones = amt.data.edit_bones
                    for bn in ebones:
                        if "DazWsrot" in bn.keys():
                            pr = bn["DazWsrot"]
                            po = Vector(bn.head) #get current bone postion
                            bn.translate(-po) #move to world center
                            dq = (pr[3], -pr[0], pr[2], -pr[1]) #change daz quartanion to blender world
                            dquat = Quaternion(dq) 
                            bp_mat = dquat.to_matrix()
                            mat_pr = bp_mat.to_4x4() #change quartanion to matrix
                            mat_o = bn.matrix #get current bone matrix
                            bn.matrix = mat_pr @ mat_o #rotate edit bone
                            bn.translate(po) #return bone postion 
    
                    bpy.ops.object.mode_set(mode = cmode)
    
            msg = "Adjust pose rotation Finish!"
            showInfo(self, context, msg)
            return{'FINISHED'}
    

    to get it work I need to reload dbz file , then atach ws_rot value as edit-bone customprop first.

  7. engetudouiti reporter

    Then I checked why some foot wear already add posed rotation, (as same as your blog), but some foot wear not add posed rotation (when import with foot pose) .

    It is because,, some vendor make foot wear which already include foot pose. (so the foot wear have no rotation value, as default.

    but some vendor make foot wear to fit non pose actor first. so when I load them without fit to, in daz studio, they deform ugry. (but keep rigs as same as non zero pose Actor rigs)

    your blog show the foot wear which already include foot pose rotation as rest pose.

    When I load those foot-wear,, without actor,, it can oad without deform.. It was advance thechnic to make foot wear (remove jcm effect etc, to better fit ) for daz characters.

    But many old foot wear not include rotation. when load them.. so it usually show broken shoes. (but when fit to actor,, with foot pose, they show real shape)

    About both case,, ws_rot tell us ,real rotation value from the rest pose of rig. and the good thing is, even though the foot wear have been posed by morph,, or controller v, ws-rot can show all posed value from rest pose of the rig.

  8. engetudouiti reporter

    Wao,, could you confirm it worked with new Commits without problem?

    I am not clever, then I do not understand well your way.. Maybe I suppose you only needed some tweak to use Blender matrix for edit bone.. (Actually I could not fully understand,, about blender bone matrix,,,, )

    I happend to set bones on world center first,, then it can solve some complex issue,..when convert quartanion and apply for edit-bone matrix.. then ws_rot worked for me,, (strange way I know) to get rotate value…

    Anyway if it have been solved,, I really apreciate,,, finally I can remove many un-necessary code, from my script \ ^^ / As frequent noisy commentater,, (I am just fun of your plug in,,) I need to say many thank you.

  9. engetudouiti reporter

    Thanks now it work ideal as I expected. if there is new issue (eg driver change etc,,) I might report again,,, Really thank you consider and try to solve this complexrequest...

  10. Log in to comment