Tuesday, October 2, 2007

Dynamic Hair and Spline IK...together.

This one came up at work today: How to drive a bone chain dynamically. This is realitivy easy to setup....so....let's go.

Go ahead and draw your joint chain. Orient your joints--always orient your joints. Here, I'm putting Y down the bone, with a pole prefrence for z-positive. Hopefully, if all goes well, this will make the joint point it's local Y axis to the next joint in the chain, and rotate it on that to get Z facing in the positive world orentation. Not always perfect, but it's a good start. The last joint has nothing to point to, so it's ignored. And if it's not, make sure that the "Orient Child Joints" box is checked so it affects the entire joint chain.

Next, choose to draw an EP curve, with at least a Curve Degree of 3 in the tool settings. Hold V and click the first and last joint to snap to those joints and complete the curve. Now, goto Edit Curves -> Rebuild Curves. In this box, reset the tool, then enter the number of joint spans in the "Number of spans" box. This will recreate the curve, making a Control Vertex for every joint in the chain. This isn't absolutly required to do, but it makes sense to have the same number of spans in each the contol spline and the joint chain.


With your curve selected, goto Hair -> Make Selected Curves Dynamic. This will...uh, well, this will make the selected curves dynamic. Doing so moves the curve from something you control into something Maya controls. In your Outliner you'll see all that Hair System stuff appear that always accompanies this kinda stuff. The curve coming from the Follicle is a draw curve, and the curve coming from the hairSystem1OutputCurves is the dynamic one. At this point, selecting the curves in the 3D view is difficult because they're in the same place. I don't need or care about the draw curve, so I'm gonna toggle it's visibility to off. Now I can easily select the dynamic curve in the 3D view. To clarify, draw = curve1, and dynamic = curve2.

When you create a SplineIK, Maya draws the Spline part for you. We want our curve to drive the SplineIK, so we don't want Maya to create one. To stop Maya from doing this, I'll uncheck the (on by default) Auto Create Curve box in the SplineIK tool settings.

To tell Maya what curve to use as the driving curve for the SplineIK, we click-click-shift-click. Click the first joint....click the second joint...hold shift...and click the curve. If Maya gets your point, she'll make an IK handle which will appear in your outliner. *stretch!*, almost done.

When you convert a curve into a dynamic curve, the curve is automatically anchored at both ends. If you hit play, the curve will only sag under the virtual gravity. If you followed this example as I've done it, when you hit play you won't see anything happen because the virtual gravity is pulling down on Y and we're vertically oriented (Y is up by default in Maya). choose the follicle in your outliner and in your channel box, set Point Lock to Base (your first click in creating the curve is the base). There are four options there, No Attach, Base, Tip, and BothEnds. Seems pretty straight forward as to what those mean, so we'll skip explanation.



Now you can test your finished Dynamicaly Driven Spline IK system by heading to the Hair shelf, choosing the follicle, and starting Interactive Playback (the green arrow icon on the Hair shelf). Move your follicle around and watch your bones go swayin' all over the dang place.


To make any use out of this, parent the follicle to what ever it is that's moving, such as....oh, I dunno, a lamp so you can puse it as a pull chain.

0 comments: