Sunday, March 14, 2010

Developing in makehuman - 3 - Morph targets

Whatever your plugin does, there's a big chance that it will modify the model. As many of you probably know, makehuman doesn't work mathematically or procedural, but artistically. This means that you don't just drag vertices when moving a part of the body, but you actually apply a morph made by an artist. There are different kind of morphs targets which are applied in different ways.
Macro targets, which are the most complex internally, are ironically the easiest to use: human.setGender, human.setAge, human.setWeight and human.setMuscle can be used to change the corresponding macro features. You will notice that height is not there. This is because you have to make the modifier yourself. We will look at that in a moment.
Another macro target, the ethnic, is set using human.setEthnic, passing the ethnic and how much of it is to be applied.
Detail and micro detail targets both come in pairs. For example one target to move a body part to the left, and another target to move the same body part to the right. Therefore you should never apply both targets at the same time. This means that when you apply one, and later you want to apply the other, you need to remove the first. While you could use human.setDetail to this, it is easier to use the Modifier class which we wrote and does all of the needed logic behind the the method modifier.setValue, it has an accompanying modifier.getValue which has the reverse logic. To use it, you create a modifier passing the two opposite targets:

modifier = humanmodifier.Modifier(human, "data/targets/macrodetails/universal-stature-dwarf.target", "data/targets/macrodetails/universal-stature-giant.target")

A value between -1.0 and 0.0 will use the dwarf target, while a value between 0.0 and 1.0 will use the giant target. Using 0.0 will remove both targets.
While using a modifier also applies the target, to keep changes interactive other targets are not reapplied and normals are not recalculated.
Once you have made the necessary changes, you commit them using human.applyAllTargets. Which does exactly what it says. It applies all the targets one by one and additionally recalculates the normals. Reapplying all targets minimizes the size of mathematical error in the final model.

1 comments:

  1. I've discovered a morph target that really needs creating: the Ballet Full Plie, or the first position of a Taekwondo Full Roundhouse. Both require that the femur rotate on its long (nominally z) axis, so that the hips can be used a full power. This can be remedied by checking both Hinge and Deform in the Blender Armature tab, but that's a workaround, not a final solution. If Artists are designing the morph targets, it would help the rest of us to know what they are deriving their designs from.

    ReplyDelete

© MHteam 2001-2010