This tutorial will walk you through the process of importing a WaveFront .obj file that was exported from DAZ or Poser 6 or version 7. By using the poserio python programs you can get a really clean import from Poser with out the need to adjust a lot of materials or uv maps after the import. The script also contains programs that will help you work around the 16 material limit in Blender. You can skip step 3 if you are not interested in how the process works.
poserio.zip updated 08/12/2007
Updates are for figures with more than 4 vertex per face. A warning is printed in the command window and the face is not created. After import you can add the missing faces.
Unzip to a suitable directory, for example:
This package contains the programs to do the imports. It also has an import and export for making Morph Targets in Poser. Those are posermtexport.py and poserimport.py. One note on morph targets, you can only move vertices, do not scale, set smooth, rotate, add or delete anything or poser will fail to apply your morph correctly.
Update your PYTHONPATH to include the new directory created above.
If you do not have PYTHONPATH set you can determine what it should include by starting command or shell window (Both linux and Windows) in the directory from step 2.
Enter python printpypath.py
The output can be used to set your PYTHONPATH environment variable. Make sure you have included the directory that contains poserio programs.
Linux: you can add it to your .profile or .bashrc in your home directory or in the shell before you start blender. The ouput from the command would be cut/pasted into the command: export PYTHONPATH=theoutputhere
Windows: bring up control panel, select system then the advanced tab. At the bottom will be a button for Environment Variables. Select that button and then under User Variables select new. Enter PYTHONPATH for the name and paste the output from the command above.
Blender does have a limit of 16 materials per mesh object. When you complete the import the figure in blender all objects you selected will become one mesh. Later in this tutorial I will have steps you can follow to collapse materials with the same UV image map into one material name. As you select your figures to export plan a head. You will be better off if you export one figure at a time.
In DAZ or Poser create, pose and apply any textures and expressions you want. Do not use Dynamic Hair, it cannot be imported correctly and will cause parts of your figure to be missing after import.
Poser: from the file menu select export, WaveFront OBJ, then single frame. From the Hierarchy Selection panel de-select Universe and select the figure and parts you want to become one object in Blender.
Select a file name the pick the following export options:
Select Ok and the object will be exported.
Poser has a python script to copy the scene inventory to a directory, including the materials. From the window menu select Python scripts. From the pop up box select Utility Functions then Collect Scene Inventory. From the Copy all selection item choose the same directory you exported the .OBJ file. When the script is done you can delete the extra items collected if you want. You only need the images, the .obj file you specified and it's associated .mtl file.
DAZ: Select File, Export, enter a name for the file. In the export options panel make sure you select the boxes for Write normals and Write UV coordinates.
DAZ will copy the images to a MAP subdirectory in the same location as the .obj file.
Any procedural textures you have used such as 3D clouds, noise etc will not get imported. Those textures will need to be re-applied once in Blender. The import process will turn each Material into a Image Texture so you will be able to easily add back any procedural textures.
The import process will make more sense if you have a basic understanding of what is in the .obj file and the .mtl file.
The .obj file is a text file that can describe 3D objects. Each line of the file is either a comment, a line starting with # or a tag line. The tags we are interested in for this tutorial are:
mtllib : This tag give the file name of the material lib, .mtl file. The poserio importer expects the file referenced by this line to be in the same path as the .obj file, or be a relative path from the .obj files path.
v : This tag is a vertex coordinate. They will be referenced as a array of tags, starting with the first one found in the file.
vt : A texture vertex coordinate, as with the v tag it will be referenced as an array starting with the first one found in the file.
vn : Vertex normal coordinate, not used by the poserio import process.
f : This is a face tag for creating the faces. The correct format is four pairs of v/vt/vn or v//vn. The number referenced is the index number of the v, vt or vn tags from the start of the file. So 62/1/62 would mean counting from 1 the 62 v tag found, the 1'st vt tag and the 62 vn tag. If there are no UV coordinates then the format is v//vn. DAZ exports incorrectly if you do not select the option for exporting vertex normals. In that case you get v/vt which will crash the poserio import process.
g : This tag is the grouping of all faces. When a g tag is found all the following f tags belong to that group until another g tag is found. The poserio import process does not use the grouping to build separate objects. By making all the objects a single mesh the ugly seams are avoided.
usemtl : The tag that shows which material section out of the .mtl file to use. As with the g tags the same material is used until another usemtl tag is found. This is the key tag to getting around the Blender 16 material limit. Later in the tutorial I have a process that will do a global change of one material to another. If both materials referenced are the same image or exactly the same material they can be collapsed into one. By doing this you do limit your ability to adjust all the material groups, however many of the materials may not need to be worked with individually. For example SkinHead and SkinScalp could be combined with no loss in most cases.
The .mtl file is a text representation of all the materials used in the figure. Even if you export only one part of the figure the .mtl file will have a full list of all the materials used in the figure. The tags of interest in this tutorial are:
newmtl : This tag starts a section, the name following the tag is the material name, same one referenced in the usemtl found in the .obj file. All tags following this one belong to that material until another newmtl tag is found.
map_Kd, map_d, map_Bump : These tags point to the image file name to be used. The image file is expected to be in the same path as the .mtl file or have a relative path name from the .mtl file's path. DAZ adds a /Map path in front of the image name. A Kd map is a normal texture map. A map_d is a map used to effect the Alpha of the image, and map_Bump is a bump map to effect the depth. One key item to take note of is any map_d tags you have. The often have a incorrect alpha value supplied in the following d tag. The preimport check process has the ability to correct this at import time. For a map_d specific options in Blender must be set or the material will not look correct. Often it's these images that cause the figure to look wrong.
Ns : The hardness tag, set's the materials hardness in Blender.
Ka : Sets the MirCol in Blender.
Kd : Sets the RGB color.
Ks : Sets the Specular color.
d : Sets the Alpha value. When also used with a map_d it should be 0. The preimport can correct this for you.
Even if the material is not a Image type it can be collapsed to save on the 16 material limit if all the values are the same, or you just wish to make them the same as another material. For example UpperTeeth and LowerTeeth have almost the same value for the Ks tag and could be collapsed if you want the teeth to look the same.
The next steps with read your .obj file and determine if there are more than 16 materials used. It will also correct the alpha setting in the .mtl file as needed. A collapse file is created that will allow you to use fewer materials in your figure. The final step is to apply the collapse file.
Bring up a command window (start/run/cmd) for windows or a shell for Linux. Change directory to the location you copied poserio.
The command to run is python importprecheck.py -c <full-path-to-collapse-file> -o <full-path-to-obj-file> -a -d
The -a is for auto correct, -d is to indicated if the export was from DAZ. Example:
An example on Windows:
The output will tell you if you exceeded the 16 material limit and the name of any materials corrected.
Edit the collapse file created in Step 3 with the editor of your choice. The content will look similar to:
The format of the collapse file is oldtag^newtag. From this example any instance of Tongue found in a usemtl tag will be replaced with SkinBody in the .obj file. You can delete lines as needed, keeping the materials you may want to alter or add textures to. It's a good idea to remove any that have transparency, you will need to adjust those, for example EyeBrows often have transparency and if found in the, should be removed.
Apply the collapse file, in the same command window enter: python collapsematerials.py -c <full-path-to-collapse-file> -o <full-path-to-obj-file>
The output will show which materials will be replaced and any occurrences of those materials.
Bring up Blender, split your screen and on one side switch to the text editor. Select open file and locate the poserimport.py in your poserio directory.
In the text editor window and select Execute script. You will be taken to the file chooser dialog, locate your updated obj file. When you select the import button the import process will start. The import process is SLOW! The blender 2.44RC1 has much better performance than the older versions for this import process.
When the import is completed you can scale the figure and hit set smooth, then edit and do CTRL-n to recalculate normals. Do NOT select the entire figure and remove doubles, that will cause sharp creases in areas like eyes and mouth.
Imports from poser may not require any adjustments in the materials. The trouble spots are eyes, eye brows, eye lashes. and any place there was transparency, check the alpha settings, hardness and adjust as needed. With Poser 7 figures such as the G2 figures you may need to select the eye lashes, and eyes and de-select traceable in the render pipeline settings if you use raytracing.
For some figures from both DAZ and Poser there will need to be adjustments depending on the figure and UV image maps used, and the lighting in Blender.
Daz usually does not have as clean an export, the mesh will end up with seams where there were different material groups. As noted in item 3 above, do not try to remove all doubles. Select the areas around the visible seams and remove doubles at those locations only. Note the seams around the neck arms and middle back.
Select the neck area, remove doubles then hit smooth once.
In this model the head skin tone does not match the body tone for the lighting shown here. This is due to the different way hardness reflection values are specified in blender. You will need to make final adjustments to those values depending on your lighting. For this model I changed SkinBody texture to spec .295 and hardness 45. The SkinHead (which was collapsed to Lacrimal) texture I set spec .295 and hardness 100.
Some areas especially eyes may have a material mapped that was intended to be layers with transparency. In those cases they may look incorrect due to the hardness value. If you selected autocorrect and daz in step four, the hardness was adjusted to be similar to what the material would have been in Poser 6. You may need to make further adjustments to the hardness value.