# HoudiniKinefx

Jump to: navigation, search

## Kinefx

Kinefx covers a lot of ground, but there's a pleasing DNA share with a lot of established houdini workflows. Basically if you've used packed prims before and wrangles, you get the core of kinefx.

### Localtransform and kinefx wrangle

For me one of the most exciting things is the core ability to treat curves as joint chains. I've experimented with doing this in the past (see CurveUnrollTutorial ), but it's quite a lot of work. Now all that stuff comes for free!

When you get into kinefx, the sections of a line are treated as joint chains. Each point gets a @localtransform matrix4 attribute. If you rotate it, it is treated as a FK rotation in a joint chain, ie, rotate the elbow, and you'll have the wrist, hand, fingers all come along too in a FK style.

This means if you animate all the rotations of all the joints, you get easy wiggly waggly setups. So:

1. Make a line with 10 segments
2. Append a skeleton sop which will create @localtransform for you
3. Append a rig wrangle
4. Try something like this:
```rotate(4@localtransform, @Time, {1,0,0});
```

When you scrub the timeline, you'll see the line curl up as each 'joint' is rotated over time. What if you increase the amount of rotation from the start to the end of the curve?

```rotate(4@localtransform, @Time*@ptnum*0.1, {1,0,0});
```

or drive with a sine wave and tweak the values a bit?

```rotate(4@localtransform, .2*sin(-@Time*3+@ptnum*0.2), {1,0,0});
```

or just be really silly, do this, and copy some lines to a sphere:

```rotate(4@localtransform, .4*sin(rand(@primnum)-@Time*2+@ptnum*.05), vector(curlnoise(@P+rand(@prinum)+@Time*0.2)));
```

Download hip: File:kinefx_starfish.hip

### FBIK

Download hip: File:kinefx_fbik_hips.hip

Not sure if this is the right way to use it, but its fun.

Bring in a rig, here I've loaded mocapbiped3, chose a walk, and imported it with the scenecharacterimport node. Split off the feet and hips, move the hips, feed those to the second input of the fbik sop, and the original rig to the first input.

FBIK will do its best to push the rig to match the positions of the bones you specify. Tweaking some weighting options on the FBIK node can help get rid of glitches.

It's not perfect, things like knees will wobble everywhere, but like I said, its fun.

### Simple skinning from scratch

Download hip: File:kinefx_skin_simple.hip

The launch docs gloss over this a little bit, you can work it out by reverse engineering some of the later examples.

Captureproximity sop is what you want. Geo to the left, rig to the right, feed that and your animated skeleton to a bone deform.

Play with the weights tab on the capture proximity to boost the number of influences, smooth out the reuslts.

### Manually drawing a skeleton

The skeleton above was drawn directly in the skeleton sop, it has lots of options to help you draw joints, mirror them, constrain to planes or inside geo etc, detail are in the sidefx docs.

Take 2 mins to go over the shortcuts and various modes, its pretty good fun. In the mp4 I'm doing the following:

• Mostly in 'freehand' mode to click-click-click the core hips-to-head joint chain
• Hit enter to swap to edit mode, tweak on, child compensate on, drag on joints to fix placement
• Select a joint, hit enter again to draw arm, leg, tail
• r.click, split to create elbow
• select shoulder/elbow/wrist, r.click, mirror and duplicate to create opposite side.

### Rig from labs straight skeleton

Download hip: File:kinefx_straight_skeleton.hip

Takes a bit of cleanup, but it works. The key thing is for the curves to have their orientation correct, ie if you were to follow the vertex ordering, the joints must flow like joints. No child joints pointing back up to the root or backwards joints, most of the errors I had were due to this.

A fix here after chatting with Henry Dean is to select the 'hips', use edge transport to calculate distance to the hips, sort by that distance attribute, and polypath to force a rebuild of the vertex order based on point/prim order.

### Rig doctor to help debug curve direction

When you get warnings of cycle errors, that implies some of your curves are backwards. Append a rig doctor, turn on 'show parent to child', and you'll see a little arrowhead to show how the curves are flowing. Red is bad. In the gif the red arrows appear if I take the resampled straight skeleton. The good one is using the edge transport, sort, polypath trick outlined above.

### Procedural weights

Download hip: File:kinefx_procedural_weights.hip

Skinning sounds like an artist thing yeah? All that falloff stuff and painting weights? Ew. You left all that behind when you joined the houdini party.

If you know ahead of time exactly what your weights are, you can 'fake' what the capture weights node does through vex. It's a little tricky, Edward Lam from SideFx gave some great pointers here.

The weight attributes made by the capture weights sops are awkward to manipulate with vex, so there's 2 helper sops, capture pack and capture unpack to convert stuff into vex friendly attributes and back again.

This setup fakes what the capture unpack node does, creating arrays of the joints and their weights per point. It also creates a tricksy detail attribute used by some skinning related nodes.

There's 2 setups in here, one which takes some circles, and makes the same number of joints and procedurally weights the skinned circles to the joints and wiggles them.

The other could potentially be more interesting (but ultimately does what the labs rigid bodies converter does if you need a full solution). It takes packed animation, creates a joint for each, transfers the packed animation to joint animation, and skins the unpacked shapes back to the joints. It's slightly off, you can see the cubes are rotated 45 degress compared to the packed source, something I'll need to work on.