Sunday, February 5, 2012

Making a skirt with makeclothes.

There have been a lot of changes to makeclothes recently, and the documentation is somewhat outdated. I will do something about that soon, but in the meantime this post will illustrate some of the changes. I will also show a different way to import the base mesh into Blender, by using maketarget.

The biggest change is that single file is obsolete. It has been replaced by the python package makeclothes, located directly under the MH/utils folder. Copy the entire makeclothes folder to Blender's addons folder, typically Blender/2.61/scripts/addons. Also copy from MH/utils/maketarget to addons. Alternatively, you can execute maketarget from Blender's text editor window. This is not possible for makeclothes, which now is a multi-file package; it must be copied to the addons folder before Blender is started. Moreover, the files must be copied again every time either Blender or makeclothes is updated. Sorry for the inconvenience.

The reason for this change is that a package can contain several files. In particular, makeclothes maintains its own UV coordinates for the helper geometry. The helper UVs in base.obj are located in a small region with alpha=0 in the upper-right corner, to ensure that helpers are invisible in MH. But the helper UV coordinates for masking need to match the UVs of the underlying body. Therefore a different UV set is necessary.

The fake UVs for the skirt helper geometry are located in an alpha=0 region, because a skirt does not always cover the legs completely. Point made.

Unless your clothing is supposed to fit very snugly to the body, it is best to relate it to the helper geometry - it is there for this reason. Consider e.g. the female chest, shown schematically in the figure above. If we model a coat on a male base mesh, the breast will be too obvious when it is applied to a woman. Conversely, a coat modelled on a female will have a strange protusion in the middle when applied to a man. In this case, the mhclo file may say that the coat is 1 cm in front of the nipple but 10 cm in front of the chest bone, which is realistic for a female but not for a male. The helper geometry will be morphed correctly and take care of this problem.

At this time the only helper geometry is a tight overall and a long, tight skirt. More will be added in the future.

In Blender, enable the Make Target and Make Clothes add-ons. They are found in the MakeHuman category.

Load the human base mesh with make_target_b25x. Press Import base obj with Load materials from Materials. Select the base mesh MH/data/3dobjs/base.obj in the file selector. This is the unique base mesh file.

Load from the MH/targets/macrodetails directory.

Apply the shapekeys. First select Basis and press the - button, the select and press -. We now have a good human mesh to attach clothes to.

Model a skirt. Set mesh type to Clothing for the skirt and mesh type to Human for the human. Rename the object to Skirt. This is important because this name will show up in MakeHuman.

Auto create vertex groups for the human. With the flag set to Helpers, only helper geometry is included in vertex groups. Then select further vertices to ignore, and press Remove vertex groups with the flag set to Selected. The picture below shows the Left vertex group at different stages of the process.

Also auto create vertex groups for the skirt. The flags are ignored for clothing, and the Left vertex groups looks like this:

Create two UV Maps. Call the first one Mask and the second Texture. Make some nice UV layout for the texture.

Now it is time to make the clothes. With both the human and the clothing selected (in either order), press the Make Clothes button. The UV layers properties are set to: Mask:0, Texture:1, Obj:1, to match order of the UV maps. The texture map will be included in the exported obj file, the mask map in the mhclo file. The mhclo file is created in a subdirectory of the directory specified just below Settings.

Export the obj file. With the clothing selected, press Export Obj file. It ends up in the same folder as the mhclo file.

Whereas we can choose any UV layout for the texture, the mask UVs must match the UVs of the underlying body. This is because there can be several clothes that partially cover the body and each other. When a clothed character is imported with mhx, the masks of one clothing covers both the body and the clothes beneath it, i.e. make them invisible in that region. This requires that all clothes have compatible UVs.

To automatically generate a compatible UV layout, press the Project UVs button. The clothing must have seams in approximately the same place as the body. This result is very good in the bulk, but UV vertices close to seams may be misplaced.

Fortunately, it is quite easy to fix misplaced UVs manually, using a trick that I figured out only recently. Select faces on one side of the seam only. It is usually clear where the misplaced vertices need to go. Repeat for the other side of the seam.

The previously exported mhclo file does not contain the correct mask UVs. To fix this, we could press Make Clothes again, and this time the correct UVs will be exported. However, making clothes is a rather time-consuming process, and it is not necessary just to export the right UVs. With the skirt selected, press Reexport Mhclo file. The existing mhclo file is updated with the correct UVs.

The tailor finally has to make the mask, texture and thumbnail images and save them in the same folder. You can look at the top of the mhclo file to get the expected file names. Or, if you prefer some other file names, change in the mhclo file.

The new skirt shows up in MakeHuman, in the Libraries > Clothes section. Without a thumbnail, because we have not made any. Select the skirt and export it as an mhx file. Using the right setting in mh_export.config, we can equip the skirt with an experimental rig. The skirt rig does not work terribly well, but something like it is necessary if we want to imitate the Marilyn pose above.

No comments:

Post a Comment

© MHteam 2001-2010