Friday, July 21, 2023

Version 1.7.1 Released

Version 1.7.1 of the DAZ Importer and MHX Runtime system has been released. It can be downloaded from https://www.dropbox.com/s/7mj32wh3bnn4rwe/import_daz_mhx_rts_v1_7_1.zip.

This is primarily a bugfix release. A number of serious bugs were discovered right after the 1.7.0 release. Those have now been eliminated, so I recommend everybody to update to the new version. Safely Installing a New Version.

There are also a few new features. The most obvious one is that the user interface has been rearranged. The DAZ Importer now takes up two tabs in the User Interface (N-panel), DAZ Setup and DAZ Runtime. One or both of these tabs can be hidden.

Support for making pose presets has been improved.

The internal working of the MHX rig has been changed. However, there is a conversion tool for old MHX rigs, so they can still be used with the latest release.





Thursday, July 13, 2023

MHX Properties are now ID Properties

If you open an old MHX rig in the latest MHX version, all panels contain only a single button named "Update MHX Drivers". What is going on?

In Blender there are two types of custom properties, often called ID properties and RNA properties. RNA properties are defined by Blender or by add-ons for all instances of a certain datatype, whereas ID properties are created on the fly and only affects a single instance. 
 
MHX has been using RNA properties for its internal functioning, because it makes the UI more attractive. In particular, Boolean ID properties are displayed as integers rather than checkboxes. However, I recently realized that RNA properties have a major drawback: they are not defined if the MHX add-on is disabled. This could happen if we redistribute the blend file to somebody who does not have the MHX add-on installed, e.g. a render farm.
Here we have posed Aiko in version 1.7.0 of the DAZ Importer and MHX RTS add-ons. We are using IK for both arms and legs.
IK for the left and right arms are controlled by custom properties called MhaArmIk_L and MhaArmIk_R, respectively. We see in the Custom Properties list that IK is enabled and that they are RNA properties, because "API Defined" is written to the right of the properties.

The IK property drives the influence of a Copy Transforms constraint for the upper_arm.L bone, which is located on the hidden layer 15. The driver value is 1.0 which is the value of the RNA property MhaArmIk_L.
Save the file and disable the MHX RTS add-on. Then close and restart Blender, so the definition of the RNA properties disappear.
Now open the file that we just saved in the new Blender session. The IK pose is gone! The IK bones are posed as they were before, but the mesh no longer follows suit.

When we inspect the custom properties, we see that the custom properties have turned into ID properties. There is a cogwheel and an X to the right of the properties rather than the text "API Defined".
If we look at the driver for the Copy Transforms constraint, we see that the path has turned red and that the driver value is 0.0. The driver looks for an RNA property called MhaArmIk_L, but that does not exist because the MHX RTS add-on is disabled.

To fix the file, we have to enable the MHX add-on again. The mesh now jumps into place because the RNA properties are defined again, but this is not a permanent solution.

All panels in the MHX tab contain the single button "Update MHX Drivers", so we have to press that.
The path to the driving property has been changed. Instead of MhaArmIk_L which is the path to the RNA property, it becomes ["MhaArmIk_L"] refers to the corresponding ID property.

Now save the blend file, disable the MHX add-on, restart Blender and open the file. The IK pose is still there, even though the MHX tab is absent.

Wednesday, July 5, 2023

Hierarchical Pose Presets

For a while the DAZ Importer has been able to export pose presets back to DAZ Studio, see the post Save pose preset. However, this was limited to ordinary pose presets, which only work on a single figure in DAZ Studio. Following a request by Rakete, the functionality of this tool has now been expanded to also generate hierarchical pose presets,

Let us consider this character. In DAZ Studio, we added the Genesis 8.1 Female Face Controls from the Developer Kit. In Blender we merge the rigs together and loaded the FACS morphs. Finally we posed both the character and the face controls in order to make a facial expression.
Now let us export the pose as a pose preset. Press the Save Pose Preset button in the Posing panel. A file selector appears. Save the preset in a directory that can be accessed from DAZ Studio, leaving the Preset Type at the default value Pose.
In DAZ Studio, select the figure and load the pose preset. The body is posed but the face is not, because the pose is only loaded to the figure itself, not to its children, e.g. the Face Control figure.

Now do the same thing again, but set Preset Type to Hierarchical instead.
In DAZ Studio, the hierarchical preset is loaded to the entire node hierarchy, both the main figure and its subfigures.
Instead of using the Face Control bones, we could create an expression using the FACS sliders.
This time we set the Preset Type to Pose And Morph.

Note that this tool does not distinguish between shaping and posing morphs; in Blender, all morphs are treated in the same way.

In DAZ Studio, we need to zero the face control pose, because the new preset will only pose the main figure bones.
When we load the mixed pose-morph preset in DAZ Studio, both the bone pose and the morph values are loaded.

Hierarchical pose presets are quite sensitive to the bone hierarchy. Therefore it is not possible to use the MHX or Rigify rigs to generate hierarchical presets, because those rigs have a completely different bone hierarchy. However, it is possible to use the Simple IK rig.

Even if it is not possible to use the MHX or Rigify rigs directly, we can still use them to control the original DAZ rig. To do so, enable the Keep DAZ Rig option when the MHX rig is generated.
This gives us two separate rigs: the control rig Genesis 8.1 Female_MHX, which has the MHX controls, and the deform rig Genesis 8.1 Female.
Pose the control rig. We can create an ordinary pose presets directly from the mhx rig (so keeping the DAZ rig was unnecessary in this case).
The pose preset can be loaded in DAZ Studio, but the face expression is of course missing.
To create a hierarchical pose preset, select the deform rig and press Mute Control Rig. The deform rig is now detached from the control rig, and the pose is baked to the deform bones, including the face control bones.

Once we have exported the preset, the Unmute Control Rig button returns control to the control rig.

Since the active object is now a DAZ rig, we can save a hierarchical pose preset.
And this preset poses the entire hierarchy in DAZ Studio.