Sunday, August 9, 2020

Automatic Root Path Extraction

 Unlike OBJ or FBX files, a file from DAZ Studio (.duf, .dsf) is not self-contained. Instead it contains pointers to other DAZ files, which may contain further pointers or the actual data. The pointers are given relative to the DAZ Studio root directories, which are listed at the top of the Content Library tab in DAZ Studio.

 

In Blender we find the root paths in the Global Settings dialog, which we open by pressing the Global Settings button just below the Import DAZ File button in the Setup panel.

 

The default root paths listed in Blender may work in Windows if you have installed DAZ Studio with the default settings. However, if you use non-standard locations for your assets, or access assets over the web, or use a Mac, these settings will not be right. 

It is absolutely mandatory that you have the same root paths as in DAZ Studio, because otherwise the Blender plug-in will not find your assets at all. The time-honored method to fix this has been to type in the root paths by hand. However, this is rather cumbersome, even if you only have to do it once if you save the settings afterwords. The manual method still works, but in the development version there is a more convenient way to do it.

 

In the to_daz_studio folder there is a new subfolder called Scripts. Copy or link this folder to one of you DAZ Studio base directories and start up DAZ Studio.

 

In the Content Library tab, the Scripts folder contains a new subfolder called Diffeomorphic, which contains a single DAZ script called save_root_paths. (Further scripts will be added later). Double-click on the save_root_paths icon.

 

The scripts starts and asks for a location where to save the file. Specify the location and press Save.

A message box informs us that the root paths have been saved.

Back in Blender, open the Global Settings dialog again, and press Load Root Paths.

 

Select the file that you saved in DAZ Studio, and press Load Root Paths

The root paths in Blender are now the same as in DAZ Studio.

Actually, if you compare with the first illustration, there is an additional directory for shaders. This is an MDL directory, which is necessary to find some textures, e.g. the DTHDR-RuinsB-500.hdr environment map.


Saturday, August 1, 2020

Global Settings Improved

The Daz Importer depends on a number of global settings, that can be changed in the Settings panel. The most important of those are the Daz root paths, which tell the importer where to look for Daz assets; if the root paths are not the same as the ones defined in Daz Studio, the importer will not find the assets.

Until now, the global settings have been implemented as Blender properties, more precisely as scene properties. This is necessary in order to be able to display and modify the properties in the Settings panel. However, there is a serious drawback. If you have saved a start-up file, it will be loaded after the Daz importer has been initialized, and if the start-up file contains the scene properties used by the Daz importer, those values will be overwritten. So it does not help if you press the Save Default Settings button. The next time Blender is started, the new default settings are loaded, but they are immediately overwritten by the values in Blender's default start-up file.
Saving a startup file
To address this problem, the upcoming version 1.5 treats the global settings differently. The global settings are now global variables, which Blender can not mess with. In order to inspect and change the settings, they are converted into scene properties only when necessary, and then immediately converted back to global variables again.
To change the settings, press the Global Settings button immediately below Import DAZ File. The Global Settings dialog now appears.
In this dialog you can now change the settings, in particular the root paths to the left. If you press OK or hit carriage return, the settings are updated, and if you press outside the dialog or hit Escape any changes are cancelled.

Note that there are no Load/Save Default Settings buttons. This because all changes are persistent, so the default settings file is automatically updated when the settings are changed. The next time you open Blender, the updated settings are loaded.

The new settings system should be compatible with the old one, but since quite a lot of code is affected, there might be some glitches that have to be worked out.