← BACK TO NOTES
2026-10-05 |
HDK HOUDINI

Rigs and Motion as C++ Nodes

There are 13 animation nodes (prefix ANIM).
They split into two sides: making bones and weights from a mesh, and making and fixing motion.

The flow of nodes

  • Mesh to rig: ANIM_AutoGuides (guide joints from a mesh), ANIM_Skeleton (a KineFX skeleton from the guides), ANIM_AutoWeight (writes the capture weights), ANIM_AutoRig (bundles all of that), ANIM_CurveSkeleton (a mesh into a curve skeleton)
  • Handles and deformation: ANIM_AutoHandle (control points from a skeleton), ANIM_Pose (posing in the viewport with IK, aim and tail solves), ANIM_Rig (LBS deformation)
  • Motion: ANIM_Kimodo (motion from text), ANIM_Guides, ANIM_MotionSolve, ANIM_MotionAttach, ANIM_Retarget

Keep the external model in another process

ANIM_Kimodo, which makes motion from text, uses an external inference model.
That model's code is not linked into Houdini. It runs as a separate process (kmd-generate), and the node reads back caches of root positions and rotations. And a cook never starts inference. Only the "Generate" button does. The rule exists so that Houdini does not freeze or crash on the model's heavy work.

Fix motion with guides

Generated motion can slide a foot or miss a target with a hand.
So ANIM_Guides creates points that say "at this frame, put this joint here", and ANIM_MotionSolve applies them to the motion.

Here is how it applies them.
Around each keyed frame it builds a smooth window (a smoothstep falloff), and adds a root offset and a two-bone IK correction scaled by that window. Then it smooths the rotations in a Laplacian style, leaving the keyed frames alone (defaults: 8 iterations, factor 0.5).

float hermiteWindow(int f, int center, int falloff) {
    if (falloff <= 0) return f == center ? 1.0f : 0.0f;
    const float u = SYSabs(float(f - center)) / float(falloff);
    if (u >= 1.0f) return 0.0f;
    return 1.0f - u * u * (3.0f - 2.0f * u);
}

Retargeting

The core of ANIM_Retarget, which moves motion onto a different skeleton, is one line.
It converts each joint's rotation into a rotation relative to the source's rest pose, then re-applies it on the target's rest pose. The scale is set automatically as the target's leg length divided by the source's. A foot lock is also available.

const UT_Matrix3F Rtgt = Rsrc * invSrcRest * RtgtRest;
tgtAnim[i].world = fromRotPos(Rtgt, tgtAnim[i].p);

Building a rig from a mesh: two methods

How a rig is built splits in two, depending on the kind of mesh:

  • Humanoid: fit a skeleton template (SOMA30, Unreal, Mixamo or quadruped) using geodesic landmarks.
  • Organic shapes: turn the mesh into a curve skeleton using Laplacian contraction plus recentering on the medial axis (openvdb). Defaults are 30 iterations, a prune fraction of 0.08 and a voxel size of 0.01, and it builds a template-free tree (Root, Spine, Branch, Head, Limb).

An organic rig works for Pose, Rig and AutoHandle, but not for Kimodo and Retarget.
Those two need the humanoid fit.

KineFX rules that tripped me up

  • transform vs localtransform: KineFX's transform is a 3×3 matrix (9 floats) plus the position P. localtransform is 16 floats. Mix them up and the bones break.
  • Finger count: SOMA30 has only thumb and middle fingertips, so retargeting from it leaves Mixamo and Unreal fingers at their rest pose.
  • Streams: data is passed around tagged with anim_stream (mesh, rest, anim, handles).

Summary

What worked in the motion nodes was moving the heavy part out of Houdini.
Inference lives in another process and the cook stays light. And for rig building, I split the work cleanly into humanoid and organic.

Next: making nodes you operate in the viewport.

Related articles

2026-10-01

Water and Clouds in C++

How my water and cloud nodes (prefix ELEM, seven of them) are built. A shore node that solves wave arrival time, caustics that gather light, how clouds are made, and what I decided not to build.

2026-10-14

Six Things the HDK Did Well

After writing 230 nodes with the HDK, here are six things I can say it did well. Speed, freedom inside the cook, the GPU, a structure that holds as the count grows, viewport interaction and verification, with numbers from the earlier articles.

2026-09-26

Building Houses and Stone Walls in C++

How my architecture nodes (prefix ARCH, 31 of them) are built, and what I learned from the node that joins stone towers to roofs. A light preview while dragging, finishing the junctions, how I verify, and the measurements.

Comments