Chain Curve Example

file Banner.png
Click here to get to find a link to the Guided Houdini Files.


This tutorial will be dedicated to the use of attributes within VEX code inside the example of curves. The goal will be to use attributes in order to create a metal chain effect on the path of a given curve such as in the image below.

The render view results. A chain moves along the path of a curve.
Getting a Suitable Curve

At the beginning we need a curve. This is the code we will want to use. It is nothing new compared to previous tutorials on curves.

curve nodes.PNG
Basic curve by parametrization creation.


If the curve is visualised with spheres you will notice how the spheres are unevenly spaced. That would be a problem in out implementation of the chains, which is why we will insert a resample node to sample evenly spaced points on the curve. This way we avoid calculating an arc length parametrization. This is the common standard to have parametrization independent curves.

resample node.PNG
Attach the resample node below to the output curve.
resampled curve.PNG
Left: the curve as we created it. Right: the resampled curve.
moving resample curve.gif
The same comparison between curves in motion.
Working with Attributes to Establish Chain Twists

Next we want to put one piece of the chain on each each point of the curve. We had already created the single piece of the chain in the previous tutorial on geometry manipulation.

chain piece.PNG
One piece of the chain in render view.

This is a good moment to use the object merge node for the first time. This node allows you to continue with the output of another node without having to connect a line from it in the network view. At the moment we have the chain curve and the chain piece assigned to different geometries in the root level of the network view.

geometry nodes.PNG
Both geometries on the root level. Only the marked result is visible.

So how to we work with the chain_piece node output inside the chain_curve? Instead of making a copy it is easier to make the object merge node reference our chain_piece node.

obj merge.PNG
The object merge node in use.
obj merge 2.PNG
The object merge node references /obj/chain_piece

To make the curve look like a chain we need to orient each chain piece along its tangen line and rotate each one as such that every follow up piece is roughly 90° twisted to its predecessor along a specific axis. This extra information for each piece can be written inside the points of the curve using attributes.

We need two more point wranglers to do this. The details of what we are doing inside the code require a wide mathematical theory which is outside of the scope of these tutorials.

computation nodes.PNG
Add two more point wranglers.

Note how the compute tangent node introduced the float attribute named pscale by writing f@pscale = . . . ;. Similarly a 3D vector was created using v@, and a 4D vector through p@. All available types can be found here.

The line in the compute parallel frame node shows how to access the attributes from other points using attrib(0,”point”,”tangent”,0); and also how to set attributes by setpointattrib(geoself(),”orient”,nextPoint,cumQ);.

Placing the Chain

Finally we can place our chain links using the copy node. Use a transform node to adjust the sizes of the links and the number of points in the resample node to have a pretty chain. The copy node uses the @orient for the orientation of the copies by default as seen on this link.

Place one chain piece at every point.

The result should be a chain traced along the path of the curve as seen below in render view. The parts of the curve with strong curvature require smaller chain links to look good.

finished chain.PNG
Final result in render view.


moving chains.gif
Final result in motion inside the scene view. The “missing piece” is due to our curve not being a closed curve.
Print Friendly, PDF & Email