Go Crazy with Dynamic Hair( Part I)

This started from the script I wrote for Mr. Hanwei Wu, he did the lighting part of the puffer ball. He wanted a puffy ball for his TD comp class.

Here is the final result:

result , and lighting done by Hanwei Wu

To do this, I came up with an idea that use dynamic hair system to control the shape node of the  geometry, treat the hair system as the deformer of the tips of puffy ball.

put a folicle on each poly face, then create a dynamic hair based on it

puffer ball algorithm

To actually do this, I figured out how Maya attaches dynamic hair curves onto geometries.

a. create a hair system. Connect certain nodes to it such as Time node.

b. create a folicle node, which act as the bridget of hair system and the hair curves, also, with the help of : folicleShape.outTrans and folicleShape.outRotate, it can xform its transform node, so that the folicle can stick to the geometry.

c. create a rest pose curve, connect it to the hair system also.

d. create a curve as a dynamic hair, connect the hair system to the hair curve.

e. connect the folicle to the hair system and also the hair curves.

the steps above sounds a little confusing, the actual codes from my scripts can be easier to explain the steps:

connectAttr( ‘time1.outTime’, (hairSystemName+’.currentTime’),f =1)

connectAttr(geoShapeName[0] +’.outMesh’, follicleName + ‘.inputMesh’)
connectAttr(geoShapeName[0] +’.worldMatrix[0]‘, follicleName + ‘.inputWorldMatrix’)
connectAttr(follicleName  +’.outRotate’, follocleTrans[0] + ‘.rotate’)
connectAttr(follicleName  +’.outTranslate’, follocleTrans[0] + ‘.translate’)
## connect rest curve
connectAttr( (curveName + ‘.worldSpace[0]‘), (follicleName + ‘.startPosition’),f =1 )
## connect follicle to hair system
connectAttr( (follicleName + ‘.outHair’), (hairSystemName+ ‘.inputHair['+ str(i)+']‘),f =1 )
## connect hair system to follicle
connectAttr( (hairSystemName + ‘.outputHair[' +str(i) +']‘), (follicleName + ‘.currentPosition’) ,f =1)
## connect follicle to hair curve
connectAttr( (follicleName + ‘.outCurve’), (hairCurveName[0] + ‘.create’),f =1 )

notice:  “i” is the the index of curves in an curves array. codes in green color are used in a for loop.

Here is the result:

all nodes created and connected

all nodes created and connected

Then do a extrusion based on dynamic hair and its corresponding poly surface.With this set up, When I move the controller curve,the extruded geometry will act the same as dynamic hair curves.

Then it comes a really big and currently unsolvable problem for me: The extrusion nodes has limitaion:

a.Because my approach needs the “extrude along curve” option of the extrude node, the node need to specify the face to be extruded, and the curve to extrude along with. The problem is, with the “exturde along the curve ” option on,  every extude node only take one face and one curve to extrude with. As a result, each face on the geometry creates a extrude node in the construction history.

b. According to the real puffer ball, I need at least 400 hundred faces extruded, which means 400 extrude node in the history. I tried with this number and it took about 10 minute to open the hypergraph.

Instead, I decide use 96 (which is a box smoothed twice) faces to get the better performance.


Before I know how the folicle node works, I came up a hard way to attach the rest curve to the move geometry.

what I did are :

Create a pointOnSurfaceInfo (or pointOnMeshInfo node in bonus tool), assign a certain UV value (certain poly face index also in the case on pointOnMeshInfo), then get the corresponding (x,y,x) value automatically.

Aassign a expression to the rest curve, which connect the position data of pointInfo node to the tranform node of the curve.

compares to the steps above,  folicles is very handy, given the U and V value of connected mesh/surface, the folicle node can automatically know where the corresponding postion of a UV point on a surface/mesh. With this method I can save two other nodes: pointOnSurfaceInfo and a expression node(when assign an expression, an expression node will be  created) . For the efficiency wise, I am very happy with the folicle rather than the others.

Also, the folicle node can be capable of position object onto the surface, such as do the same thing as the famous “rivot” MEL scripts does, and  it can be used to stick object to either dynamic simulated or keyed surface.

Leave a Reply