Advanced tips for working with Hair
 
 
 

The following are suggested tips for working with Hair.

Max Hair Density option variable

It’s helpful to know the following option variable:

createHairMaxDensity

Its default value is 100. To increase this value you could type:

optionVar -intValue createHairMaxDensity 150;

This determines the maximum rows/columns of hair you can create or paint on a surface. The follicles are named based on their position within a grid of this resolution. The reason for this naming is the Paint Hair Tool, which relies on the naming to find the hairs at a given UV position.

If this variable is greater, then the maximum number of paintable follicles on a surface will be greater; however, painting will be also slower, even if painting low follicle densities. If you change this variable then previously created hair systems will not be paintable (painting in one area may affect follicles that don't lie under the brush).

Decreasing the value of the variable might help if painting hair is slow, although you won't be able to create as high a density of follicles.

The default is a 100x100 grid, which is a max of 10000 follicles per surface.

Using the pfxstrokes command

The basic use of the pfxstrokes command is to dump Paint Effects tube information to a file. This can be useful to generate curves from Paint Effects or to send information to another renderer. The format for the data is different for hairs and brushes with Tubes turned on.

Paint Effects can call a runtime and create MEL scripts. These are defined as a string attribute on the brush node: paint create func, and paint runtime func. You set the string to the name of the function to call. This MEL function has a specific set of arguments that must be passed in and returned. The workflow is to copy one of the provided template MEL files, change the function name and file name and then edit the internals of the function. If you have any runtime or create functions set on the brush they are called as the stroke is drawn. The pfxstrokes command fakes a redraw call of the stroke without drawing anything. Therefore these scripts will also get evaluated when the pfxstrokes command is invoked.

Using a follicle node as a point on poly constraint

The follicle node can be used as a point on poly constraint. One method is to create some hairs, then delete everything except for the follicles. For example, delete the hair system, pfxHair, and Start position curves. You can then parent an object under the follicle. Or you can use the follicle node in scripts.

The following example script constrains a cone to the surface of a poly sphere. The cone will move relative to the normal and tangent at the defined uv point on the poly. (It will appear at the sphere center if the UV is set to a value not defined on the poly uv set.)

// create a cone, poly sphere and a follicle node
string $sphere[] = `polySphere`;
string $cone[] = `cone`;
string $fol = `createNode follicle`;
// get the parent transforms of the follicle
string $folTform[] = `listTransforms $fol`;
// connect the sphere to the follicle
connectAttr ($sphere[0] + ".outMesh") ($fol + ".inputMesh");
connectAttr ($sphere[0] + ".worldMatrix[0]") ($fol + ".inputWorldMatrix");
// apply the follicle output positions to its own transform
connectAttr ($fol + ".outTranslate") ($folTform[0] + ".translate" );
connectAttr ($fol + ".outRotate") ($folTform[0] + ".rotate" );
// parent the cone under the follicle
parent -r $cone[0] $folTform[0];
// the default uv of 0 0 doesn't exist on the poly sphere, so we set it
setAttr ($fol + ".parameterV") 0.5;
// rotate the cone to point along the normal
setAttr ($cone[0] + ".rotateY") -90;

Attaching a skipping rope (dynamic curve) to hands

Use a Transform constraint and group or constrain the hairConstraint node to your moving object. This should lock the dynamic curve so it follows twists and rotations of the object and behaves like a spring with an attachment of stiffness. If the dynamic curve is not attaching well, then it is a bug with the constraint. The relative constraint position is determined at the start frame, therefore there will be no force applied at the start frame. The Start curve needs to be modeled through the grasping hand.

The skipping rope case can also be handled by grouping the follicle under the hand near the base, then using a Transform constraint at either end of the rope grouped to the other hand. However, you can’t constrain the start point using the No Attach option for the Point Lock attribute in the follicleShape node. With No Attach, the start point keeps moving under gravity and is not pulled by the curve tension by constraints.

Hair as a wire deformer

Hair curves can be useful for wiggle effects when parented to the moving object and applied as wire deformers. The hair can be used as a wire deformer to make all or part of a surface dynamic.