Friday, August 18, 2017

New release candidate

A new release candidate for version 1.2 of the DAZ importer can be downloaded from https://www.dropbox.com/s/x1tkb0khjycq251/import-daz-v1.2-20170818.zip. There are two improvements compared to the previous RC:
  1. I learned that you can import Poser files into DAZ studio and save them as DAZ files, which can then be imported into Blender. However, these files are slightly different from the native DAZ files, and they caused some errors in the import scripts. These bugs should now be ironed out.
  2. The Rigify add-on was changed in Blender 2.79, which caused Rigify conversion of DAZ armatures to stop working. The new RC should work with both old and new Rigify.

Poser import

Here is how to get a Poser file into Blender. Start by importing the file into DAZ Studio.

Select File > Import

and navigate to the Poser file (.cr2, .pz2, ...). Repeat this step to add clothes, hair, etc.


Apparently the clothes fitting is not perfect.

We could save the character as a DAZ file now, but then we would not be able to pose her in Blender, because Poser figures are skinned with envelopes whereas the DAZ importer only handles vertex groups. Fortunately, we can convert to vertex groups in DAZ Studio.

Select Figure > Rigging > Convert Figure to Weight Mapping.

We get to choose between TriAx and General Weight Mapping. This choice is not terribly important, because TriAx will be converted to general weights in Blender anyway, but General is probably the best choice. here.

This step has to be repeated for every figure in the scene, i.e. for each piece of clothing.

Finally we export the final world-space coordinates to a .json file using the basic data exporter that comes with the DAZ importer. See the blog post on JSON fitting for details.

Now we can import the Poser character just as any other DAZ file. In my example there were a lot of extra nodes that correspond to empties in Blender, but it is easy to get rid of those. Just select the empties by type and delete them.


Rigify

The Rigify add-on was changed in Blender 2.79. I am sure that this is a great improvement, but the update had the side-effect that Convert To Rigify button in the DAZ importer was broken. Should be fixed now.

The meta-rigs are clearly different.

So are the rigified versions of the same DAZ Rig.

The new Rigify has a face rig, but the DAZ importer ignores that. DAZ characters already have a great way to do facial posing, with carefully crafted facial morphs or a carefully weighted face rig, and there is no simple way to map that to the Rigify face rig. The face bones in the rigified character appear on the otherwise unused bone layer 2.








Sunday, August 6, 2017

DAZ Importer version 1.2

The DAZ importer is a tool for importing native DAZ Studio files (DAZ User File *.duf, DAZ System File *.dsf) into Blender. It also contains some tools to make the assets more animation friendly.

Release candidate 2: https://www.dropbox.com/s/x1tkb0khjycq251/import-daz-v1.2-20170818.zip
Main documentation page: http://diffeomorphic.blogspot.se/p/daz-importer-version-12.html

Since the previous stable version was released half a year ago there has been several improvements and additions.
  • A DAZ Studio plug-in for exporting the final world space coordinates for vertices and bones.
  • Limits on the number of facial expressions overcome, using handlers for bone drivers.
  • Material improvements, in particular for Cycles.
  • Posing improvements.
  • Many small bugfixes and additional features.
The most signicant improvement is the DAZ Studio plug-in. In previous versions Wavefront or Collada files could be used to find the final meshes with all morphs included, but this did not always work correctly. In version 1.1 I also attempted to deduce the final locations directly from the DAZ Studio files. While this in theory must be possible (after all, DAZ Studio does it), I never got it to work right, especially not fitting clothes to arbitrary morphed meshes. After I started to use the DAZ Studio plug-in to export the final world-space coordinates, meshes have always looked the same in Blender as in DAZ Studio.

The script has mainly been tested with DAZ Studio 4.9 and Blender 2.78c on Windows 7.

Windows 10 and non-ascii characters

The Daz importer has mainly been developed on my home computer, although I have occasionally tested the code at work. Both computers are very similar: both run Windows 7 and my user name on both is Thomas, which is a standard Christian name without any strange characters. However, I also own a laptop running Windows 10, which I have never used very much, but I thought that it would be a good idea to test the code on it.

So I created a new user on the laptop, whose user name Åke Öst contains non-ascii characters, and downloaded Blender, Daz Studio, and the Daz importer. Saving the .duf file in Åke's user directory worked fine, and I could also export a json file to the same folder. However, when I tried to import the .duf file, the error below was encountered.


In Python the current user's home directory is represented by the string ~, which in this case should evaluate to

C:\Users\Åke Öst,

but instead Python thinks that it is

C:\WINDOWS\system32\config\systemprofile.

Since no directory with that name exists, the importer can not find the paths to the Daz directories, and the error is issued to alert the users about this fact.


We can inspect the paths at the top of the Settings panel. Both the first Path to DAZ library and the Path to output errors start with the flawed directory and will not be found. Fortunately, this problem is easy to fix. Simply replace the incorrect beginnings with the right one (the paths really contain the substrings "Åke Öst", even if Blender uses a font that makes it indistinguishable from "Åke Ost". Finally press Save Default Settings to avoid having to do this correction every time Blender starts up.


Behind the scenes another problem has been solved. The settings are stored in a file in the current user's home directory, but as we just saw Python failed to find that. If the home directory is not found, the script instead tries to put the settings file in the same directory that the script is stored in. Since this is usually located somewhere under the home directory, the user should have both write and read permissions. At least it worked for me.

The non-ascii characters turned out to cause one more headache. The import script is stored in a single location, and then I have made symbolic links (hard links or junctions in Windows lingo) from Blender's addons folder. This means that I don't have to update the script when a new Blender version comes out, only the links. However, I make the links by running the mklink /j command at a DOS prompt, and that mangles the non-ascii characters. The string "Åke Öst" becomes "+ke Íst", and no link is created.

There is probably some way to make a terminal window understand non-ascii characters, but instead I downloaded the Link Shell Extension, which is a graphical tool for making links.  Worked like a dream. Just be sure to download the appropriate prerequisite package before the tool itself — both are linked to on the tool’s download page.

While non-ascii characters caused some headache, they are still within the UTF-8 character set. The code has not been tested with systems that use Unicode, and I am completely sure that new problems will show up in such settings.