daz3d / DazToBlender

Daz to Blender Bridge
https://www.daz3d.com/daz-to-blender-bridge
Other
200 stars 46 forks source link

G8 shoulder JCMs are incorrectly exported #175

Open veryfancypants opened 11 months ago

veryfancypants commented 11 months ago

In G8, this specifically affects the four JCMs called "pJCMShldrFront_*110Bend*". Other characters may be affected too.

Take pJCMShldrFront_n110_Bend_p90_L (Female) in particular. It appears to be defined in Daz, using radian units, as:

pJCMShldrFront_n110_Bend_p90_L = clamp(CTRLMD_N_YRotate_n110 * CTRLMD_N_ZRotate_90)
CTRLMD_N_YRotate_n110  = clamp(lShldr_rotation_y * -0.009090909)
CTRLMD_N_ZRotate_90 = clamp(lShldr_rotation_z * 0.11111111)

In the export (FIG.dtu), I see:

            "Label" : "pJCMShldrFront_n110_Bend_p90_L",
            "Links" : [
                {
                    "Bone" : "lShldrBend",
                    "Property" : "CTRLMD_N_YRotate_n110",
                    "Type" : 5,
                    "Scalar" : 1,
                    "Addend" : 0
                },
                {
                    "Bone" : "lShldrBend",
                    "Property" : "CTRLMD_N_ZRotate_90",
                    "Type" : 3,
                    "Scalar" : 1,
                    "Addend" : 0
                },
                {
                    "Bone" : "None",
                    "Property" : "BaseJointCorrectives",
                    "Type" : 3,
                    "Scalar" : 1,
                    "Addend" : 0
                }
            ],

The logic that converts this into a driver (https://github.com/daz3d/DazToBlender/blob/master/Blender/appdata_common/Blender%20Foundation/Blender/BLENDER_VERSION/scripts/addons/DTB/DtbShapeKeys.py#L494-L519) does not even know what "CTRLMD_N_YRotate_n110" is. (It is not included in FIG.dtu. There is a definition for it in https://github.com/daz3d/DazToBlender/blob/master/Blender/appdata_common/Blender%20Foundation/Blender/BLENDER_VERSION/scripts/addons/DTB/DataBase.py#L381, which seems to be correct except for missing a clamp, but that code is not executed as part of normal import process.) So it simply pulls in the corresponding Euler angle. And, because of link type 5, it also includes "self.value" in the formula, which is completely wrong (it makes the formula recursive.)

The resulting formula is: (self.value+(a_001*57.3)+0)*((b_001*57.3)+0)

but, as far as I can tell, it should be

clamp(a_001*-0.521)*clamp(b_001*0.637) where a_001 = lShldrBend rotation_z and b_001 = lShldrBend rotation_x.