Go Crazy with Dynamic Hair( Part I)

May 28th, 2009

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.

Notes:

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.

A little script to generate a nautilus

May 8th, 2009

To help my friend to generate a nautilus shell model, I’ve tried to write a script to model it.

And I found the math referrence here

screenshot of generated model

screenshot of generated model

According to the math, the shape of the nautilus majorly depends on two constant value a and b

and the the corresponding pymel codes are:

r = a*exp(radians(Delta_angle*n)*cot(b))
x = r*cos(radians(Delta_angle*n))
if(n ==0):
y = 0
else:
y = 10*(rBefore -r)
z = r*sin(radians(Delta_angle*n))

Then the rest are just create circle based on the calculated point positions, then do a loft

What’s funny was before I finish this script my friend had already done his model by hand….

At least is was fun though.

And two days after this, Sandro asked me how to write a spiral ST coloration in RSL,

showed him the algorithm in 5 minutes, happy coincidence.

currently editing the blog pages, sorry for the viewing problem

May 6th, 2009

I’m switching the blog theme from the defult to a theme that has my design…. To finish this I have to deal with PHP stuff which is not a enjoyable thing for me right now. But anyway, have something to learn is alwasys good.

Sorry for the mess going on in my blog now, this may last for a little while.

Ling

Start to Write a Ray tracer

April 23rd, 2009

Inspired by MS. Marilyn Friedman from Dreamworks, I started this afternoon trying to write a ray tracer.

When I was interviewing with Marilyn, she told me that at Dreamworks, the effects challenge program is actually teaching people to write a raytracer.

For me, why not try to write one by myself…
So this is the start.

I installed Visual Studio and MSDN on my laptop this afternoon, and did some researches about the C++ raytracer.

here are some ref links:
ref01
ref02
ref03
ref04
ref05

Now let’s do something

Spring 09, my first website

April 15th, 2009

I finally had my website… Cheers for all the awesome people at Monty..