15
$\begingroup$

So Generate chain using GN is simple, right? Resample curve, instance torus aligned with tangent vector and rotate every odd instance 90deg. So easy. If you have a smooth curve, it looks ok.

But things goes uncanny, then curve is... too curved...

enter image description here

So here that I ended so far. Instead of Resample curve, I use sample curve in 3 points:

enter image description here

2 point is to get the tangent vector, and 3rd is to make corrected targets for the tangent vector:

enter image description here

It makes this setup a little bit better, but still not great.

Without correction:
enter image description here

With correction:
enter image description here

As you see, spawn points should be also moved to get better result.

The second problem is related to twisting.

How to perform "minimal twisting" here? Maybe accumulate field is required here? enter image description here

Do you have any thoughts? Here is the blend file to play with:

UPD.

I've added correction for distance between torus, so it looks better now:

enter image description here

But twist is still a problem:

enter image description here

$\endgroup$
1
  • $\begingroup$ Do you care about interpolation? You can make a chain that solves the first problem, although at a performance cost, but there are some smooth changes to the curve that won't result in smooth changes to the chain (think about a loop closing.) I would measure the links not by distance along the path, but with repeated spherical booleans with the path, choosing that intersection closest to the tangent ray at the center of the sphere. A similar issue probably exists for the second: to reach the "proper" twist, the shortest interpolation is through wrong twists. $\endgroup$
    – Nathan
    Nov 23, 2023 at 19:03

4 Answers 4

6
+500
$\begingroup$

Not a perfect solution! but I think it solves the twist and the distance between chain links are equal.

enter image description here

  • It first resample the curve producing points that are at equal distance (the links length).
  • This curve is subdivided once and the tilt is set so that we have 90° between point N and point N + 2.
  • The curve is transformed into point in order to have tangent and normal.
  • Then it creates an instance for every point with a odd index.
  • Instances are rotated to be X aligned to tangent and another axis rotated around normal (as normal reflects the tilt).

Resampling with equal distance between two points:

enter image description here

The principles: iterating over the curve factor (0 to 1) and at each step using a dichotomy to find the next factor so that the related point is at the wanted distance (from the previous point).

  • The inputs:

It presumes a resulting point count based on the 'standard' resampled point count (we should have less points as a result).

Start with the position for the first factor (=0).

Calculate the base factor extension as the chain link length divided by the curve total length.

  • Outer loop:

Calculate the next factor 'max' value (4 times the wanted length which should be enough if the curve is not too curly).

Engage the dichotomy (see below).

Take the resulting factor coordinate and add it to the result (but only if we are not over the curve last point).

Set the found factor as starting factor for the next iteration.

  • Dichotomy:

The result is guessed to be between factor 0 and 'max' next factor.

Calculate the distance at the middle of these two previous.

If the distance is greater than the wanted distance then next guess is between factor 0 and the middle and if not, next guess is between the middle and next factor.

Having 12 (for instance) iterations over that seems to be efficient enough (fast and with an accuracy around 0,025%).

enter image description here


But not perfect... in fact we may need more complicated things.

In this situation we may rotate this way (3D cursor at center here):

enter image description here

But in this situation, this way:

enter image description here

And real situations should be the mix of the two...

$\endgroup$
2
  • $\begingroup$ Looks very good! $\endgroup$
    – Crantisz
    Nov 24, 2023 at 12:45
  • $\begingroup$ despite it is not perfect, thank you @Crantisz. I've thought a bit more about it, but was not able to concretely go further. If you want to talk about it, tell me. $\endgroup$
    – lemon
    Nov 30, 2023 at 17:22
2
$\begingroup$

I think there are three main steps to get the chain to look right in most situations:

  1. Instance each chain link at a perfect distance from the previous one.
  2. Rotate every other chain link by 90 degrees.
  3. Modify the rotation of the instances to align them with the vector from the current point to the next.

This is a screenshot of the results so far.

Results

There are three main issue with this setup:

  • The rotation of the last link is broken, since we're calculating the vector using the next point, and the last instance doesn't have a next point.
  • Sharp corners are likely to cause issues. Even if the links are positioned correctly, they are likely to clip through each other.
  • Adding too much tilt to a curve point can cause clipping issue as well.

I think the first two issues should be addressed, but the third one seems fine to me, as the user is expected to be mindful when applying tilt. The solution we implement for this can take away too much control from the user.

I carried out the following extra steps to address the first two issues.

  1. Remove the last chain link. It is possible to add a condition for the calculation of the last vector, but this is much simpler.
  2. Set the handle types to auto; however, this significantly changes the shape of the curves. That's why I decided to resample the curve before this step and give the user control over the resample distance.

I attached a screenshot of the final node setup and the blend file (Blender 4.0) below.

Node Setup

$\endgroup$
1
$\begingroup$

Probably, you should try to make your chain more stable by simplifying the shape of the curve. In this solution, I break the curve into straight segments and attach chain links to the midpoints of the segments.

Though it is still possible to make my chain go wrong in some positions.

enter image description here

$\endgroup$
2
  • $\begingroup$ Unfortunately, it doesn't solve the issue. It has quite similar results to basic methods. $\endgroup$
    – Crantisz
    Nov 23, 2023 at 13:12
  • $\begingroup$ @Crantisz looking at this, it seems to me this should solve the twist issue you mentioned with minimum twist. $\endgroup$
    – shmuel
    Dec 29, 2023 at 17:49
1
$\begingroup$

There is no such thing as Perfect Chain Generator.

It could be great only for making static images because animating such chain would be too "jumpy". Why there is no perfect chain generator? Because you have to go through all possible cases at the sharp corners after the resampling of the curve, which cannot be done with simple math or logic blocks. Also due to complex reasons you can't get a perfect resampled curve segments - so some of the segments will be less than or greater than the specified resampling length. You have to take this also into account. Going in 3D space complicates things even more. And if you really want to have a perfect chain you have to take into account the surface on which the chain curve sits and include a random offset from the initialized 90 degree link rotations so the chain lies naturally on it.

Hopefully in the future Blender will combine GeoNodes with Physics simulations.

My answer is:

Currently what you could do is just to draw your chain curve with disconnected segments at the problematic areas, then add the missing links (pun intended) manually introducing an artistic touch to it.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .