Saturday, April 19, 2008

Spine Rig Part 2: Maya and Houdini implementation

It's been a while since my last post, sorry about that but I've been kind of busy. Anyway I found some time to put together 3 files, 1 Maya file and 2 Houdini files. 
The Maya file is the 1:1 implementation of the diagram presented in my last post. For 
implementation I used utility nodes. Here is the hypergraph shot with the relevant nodes:
You can download the Maya file here:
The first Houdini file is the 1:1 implementation of the diagram. Notice that instead of utility nodes I used expressions. The expression to compute the stretch ratio is on the spineCurve object in the Custom folder and it looks like this:
((arclen("./OUT_ARCLEN", 0, 0, 1) - ch("originalLength")) * ch("../spineOptions/spineStretchiness") + ch("originalLength")) / ch("originalLength")
  • arclen() computes the arclength of the node, OUT_ARCLEN, inside the spineCurve object.
  • ch() is a channel reference to other parameters, something like connections in Maya.
Now that I have the ratio I wrote this expression in each bone length parameter:
ch("../spineCurve/stretchRatio") * ch("originalLength")

The Houdini file is located here:

As you can see in both files you have one parameter to control the stretchiness and the spine behaves in the same way but there are 2 different ways. One uses utility nodes and the other uses simple expressions. Now I could build a Maya file that uses expressions too but I'm after the speed of the rigs and using utility nodes is the fastest way in Maya. 

But some Houdini users may say that there must be a "Houdini way" build this spine. Next I'm going to talk about this way, to please the users and point some interesting advantages.
The file in question is here:

Once you open the file you'll notice that is significantly lighter than the other one. That's because I don't have the 20 bones anymore. I have small cubes where the bones should be. If you go inside the spineCurve node you'll discover this network:
This network is a bit different than the one that belong to the bones version by a couple of nodes. The most important one is the carve node. The carve node lets you to cut a curve the way you want. In my case I'll cut it twice in U.
I jumped the gun here and implemented new features because it was very easy, the spine compression and hip/chest lead. 
Spine compression is a parameter that allows you to compress the spine, or slide the spine down along the curve. 
Hip/Chest lead will let you decide with which part of the body you want to lead. This translates into which part you want to stay put when stretchiness occur.
The other important piece in our puzzle is the resample node after the carve. This node basically stands for the whole bone network. The node resamples the curve in linear segments, how many, in my case 20 because I had 20 bones in the other example.
Next I copied onto each curve point a cube. I've done this for purely visualization purpose.  
Notice that the stretch ratio expression is the same but now instead the bone length expression I have 2 expressions on the carve node.
First U:
(ch("../../spineOptions/hipChestLead")) * (1 - ch("../stretchRatio"))

Second U:
ch("../stretchRatio") + (ch("../../spineOptions/hipChestLead")) * (1-ch("../stretchRatio"))

Play with the parameters and see how the two values changes.
The biggest advantage using this method is the fact that on stretchiness = 1 the last cube will always be where the control point is regardless how crazy the curve shape is. This doesn't happen in a regular spline IK solution. 
Please watch the following movie for a short overview of the 3 files and to see what I meant by the advantage mentioned above. 

Here is the same video in higher resolution:

Next blog entry should be on implementing the spine compression and hip/chest lead across the board and  twist/stabilizing the spine.

see ya soon


bclark said...

Really Nice Post but I had a quick question about the mult/divide nodes per joint on the maya skeleton instead of just having one of them feed each skeleton translate?
It looked like each joint was the same distance apart? I can think of reasons why you would have this per joint but I figured I would ask what your reason was.

Great blog. I met you at the Houdini booth at Siggraph last year and you gave me a great overview of how the new rigging shelf worked in Houdini.

Anyway, I am happy to see another great rigging recourse around.


calin said...

Great comment! Yes you are right, I could have only one multiply/divide if I presume that all the joints are equally distributed. This is a more generalized solution that you can use if joints aren't equally distributed.
So if you know that each joint has the same initial length you can get rid of all the extra multiply/divide nodes


-:- said...

The Hi-Res video is not available any more. Will you make it available soon? This blog looks really helpful, as I'm learning both Maya and Houdini.


calin said...

I'll look into another hosting site. Thanks for pointing it out.

pablo sepulveda said...

Hi calin great videos
how can create a colum with auto contact to ground in maya?

jay said...

I wonder if you're aware... the houdini files that you posted do not work. I downloaded them, but they're do not have any nodes in them. Are you planning to update them?