Unity JCM Controller Script
Roland1234
Posts: 31
I'm writing a script to drive JCMs in Unity but am having trouble undestanding the JCM .dsf files correctly. I think it's the formulas node that has what I need but sometimes it looks like this:
"formulas" : [
{
"output" : "Genesis8Female:#pJCMThighFwd_115_L?value",
"operations" : [
{ "op" : "push", "url" : "lThigh:/data/DAZ%203D/Genesis%208/Female/Genesis8Female.dsf#lThigh?rotation/x" },
{ "op" : "push", "val" : [ -115, 1, 0, 0, 0 ] },
{ "op" : "push", "val" : [ -57, 0, 0, 0, 0 ] },
{ "op" : "push", "val" : 2 },
{ "op" : "spline_tcb" }
]
}
]
{
"output" : "Genesis8Female:#pJCMThighFwd_115_L?value",
"operations" : [
{ "op" : "push", "url" : "lThigh:/data/DAZ%203D/Genesis%208/Female/Genesis8Female.dsf#lThigh?rotation/x" },
{ "op" : "push", "val" : [ -115, 1, 0, 0, 0 ] },
{ "op" : "push", "val" : [ -57, 0, 0, 0, 0 ] },
{ "op" : "push", "val" : 2 },
{ "op" : "spline_tcb" }
]
}
]
other times something like this:
"formulas" : [
{
"output" : "Genesis8Female:#pJCMThighSide_85_L?value",
"operations" : [
{ "op" : "push", "url" : "lThigh:/data/DAZ%203D/Genesis%208/Female/Genesis8Female.dsf#lThigh?rotation/z" },
{ "op" : "push", "val" : 0.01176471 },
{ "op" : "mult" }
]
}
]
{
"output" : "Genesis8Female:#pJCMThighSide_85_L?value",
"operations" : [
{ "op" : "push", "url" : "lThigh:/data/DAZ%203D/Genesis%208/Female/Genesis8Female.dsf#lThigh?rotation/z" },
{ "op" : "push", "val" : 0.01176471 },
{ "op" : "mult" }
]
}
]
Is there some documentation somewhere on how to interpret these values?
Post edited by Roland1234 on
Comments
Ah, I found the documentation:
http://docs.daz3d.com/doku.php/public/dson_spec/object_definitions/formula/start
The real issue now is how to implement this "spline_tcb" operation...
FYI, I've added JCM Controller support to the latest Daz Bridge Library:
https://github.com/daz3d/DazBridgeUtils/commit/ab4835549030388f7626fffb2eae3d3e862a1ae2
This info is exported in the DTU file. It's the JSON object structure used by Blender's Auto JCM implementation.
Cool - looks like that's just exporting the JCM info to the DTU file, or are you also adding a component to implement the JCM in Unity?
I manged to hack together a Unity script to drive JCM morphs. It was much more complicated than I had hoped but I got the basic idea working.
One of the main issues I ran into was the need to access the morph formulas: I had to access the registry to get the Daz library path and parse the actual morph DSF files. So my next question I guess goes to @danielbui78: Will we be able to, or are there any plans, of incuding the morph formulas in the DTU file? So far I only see the morph names and labels being exported.
Congratulations! Great work. JCM information is already exported in the DTU, but you have to build with the correct version of the Daz Bridge Library: https://github.com/daz3d/DazBridgeUtils
I will try to update DazToUnity to use the latest version of the Bridge Library for the next release. You can use the Bridge Library to build a Scriptable Bridge Plugin and use that to output DTU/FBX files. Or you can just use the DazToBlender/C4D/Maya bridges and have them output FBX/DTU and copy those to Unity -- they should be compatible with Unity, and will have the extra JCM info.
Awesome, that's exactly what I was looking for: you got the joint orientations and limits and everything. Just a minor comment: It looks like the DTU has redundant Morph and MorphNames nodes?
Are morph formula operations defined by the MorphLinks[].Links[].Type property? I see values of 0, 3, and 6. I can sort of guess 6 is spline_tcb but it seems both 0 and 3 are multiply?
Yes, there is a LOT of redundancy to maintain compatibility with 5 different bridges that use DTU files. As we work towards unifying more bridge code, we'll slowly streamline the DTU file. For now, it is a "Rosetta Stone" of Daz Iray Uber information for the different bridges.
This is from the DtB code that uses the morphlinks entries: https://github.com/daz3d/DazToBlender/blob/da8a97d665784c286562bc82eb88db1f7eba31c3/Blender/appdata_common/Blender Foundation/Blender/BLENDER_VERSION/scripts/addons/DTB/DtbShapeKeys.py#L156-L187
From Daz SDK Documentation:
The types of ERC that can be represented by this class.
Enumerator: (aka Type Values 0 - 6)
This type of ERC is the most common, and implements the formula f(v) = v + (c * m) + a where:
v
is the current value of the property this ERC link resides on.c
is the current value of the control property that drives this ERC linkm
is the scalar of this ERC linka
is the addend of this ERC linkThis type of ERC implements the formula f(v) = (c / v) + a where:
v
is the current value of the property this ERC link resides on.c
is the current value of the control property that drives this ERC linka
is the addend of this ERC linkThis type of ERC implements the formula f(v) = (v / c) + a where:
v
is the current value of the property this ERC link resides on.c
is the current value of the control property that drives this ERC linka
is the addend of this ERC linkThis type of implements the formula f(v) = (c * v) + a where:
v
is the current value of the property this ERC link resides on.c
is the current value of the control property that drives this ERC linka
is the addend of this ERC linkThis type of ERC implements the formula f(v) = v - c + a where:
v
is the current value of the property this ERC link resides on.c
is the current value of the control property that drives this ERC linka
is the addend of this ERC linkThis type of ERC implements the formula f(v) = v + c + a where:
v
is the current value of the property this ERC link resides on.c
is the current value of the control property that drives this ERC linka
is the addend of this ERC linkThis type of ERC is used to define value by a parametric function f(v) = v + P(c) where:
v
is the current value of the property this ERC link resides on.c
is the current value of the control property that drives this ERC linkYay! Thanks @danielbui78. I don't know that I could have found that in the docs.
I felt like sharing my results. Simply extract the contents into your Unity project, go to your figure's root object, add the "Daz Jcm Controller" component and click the "Load JCMs" button in the inspector to initialize everything. There's bound to be mistakes and misses so it'd be nice if people would point them out here.
You will need the latest Daz Bridge Library DTU file so I'll echo danielbui78's advice to use the latest Daz->Blender bridge plugin to generate it (it ends up under C:\Users\{name}\Documents\DAZ 3D\Bridges\Daz To Blender\Exports). But he totally promised to update the Daz->Unity plugin really, really soon. Like, tomorrow, probably.
Great work! I will try to test it out over the weekend. I'm hoping to get a new version of the DazToUnity bridge with JCM output in the DTU posted to Github by late tomorrow. It will probably not be updated to Daz Central / DIM until next week.
This is only a developmental version -- needs more internal and external QA testing before it can be pushed to Daz Central:
https://github.com/daz3d/DazToUnity/releases/tag/2022.1.pre.1
Edit: I tested the build from the link above with the Daz Jcm Controller -- AWESOME! I have only been able to test out for a couple of minutes to confirm that it works, but saw that the morph sliders on the Skinned Mesh Renderer control were correctly locked out and updating as I posed the skeleton! Congratulations again, @Roland1234! Please make a video to share when you have time. Thanks!
Hi everyone! i can't solve this problem. I used daz to unity bridge and, the shirt JCMs are exported but there doesn't seem to be a "driver" that activates them when moving the arms.
(a few days ago I wrote a post with more info and photos)
I downloaded DazUnityJcms.zip unzipped and used as a patch for the Assets in unity folder so:
Now I created a monster :D why?
Hi there! I can confirm that it's working, but it's looks terrible at high angle rotations but pretty good at low angles. I think it's because daz jcms are made for dual quaternion skinning and unity not support that. Am I right or missing something?
This should have been fixed in the Bridge by now with good performance, morphs or Unity run time scripts should definitiely not be needed it's a bone rigging issue Daz can fix.
You've got this Daz!