1
$\begingroup$

I need to do "Array" and "Curve" modifier type thing by geometry node. Curve needs to be moved by empties. And the result is the 1st picture and problem is when I move empties instance objects can't keep its space between them and they have undesirable space. I would like to do something like 2nd picture. When I move empties, object moves but they keep initial space. Just like geometry node instance only moves on curve. How can I achieve this? I added blend file so check it please.

enter image description here

enter image description here

$\endgroup$
3
  • $\begingroup$ I assume you are using a 'curve to points' node to generate the points for the instances? If you have it set to 'Count' it will generate as many points as you tell it and divide them equally along the curve. If you set it to 'Length' it will separate the point a specified length and generate as many point as needed to fill the curve. If you are deforming the curve you probably need the second one. $\endgroup$
    – Cornivius
    Commented May 21 at 11:38
  • $\begingroup$ Side Note: The provided file is crashing Blender 3.6.8. $\endgroup$ Commented May 21 at 21:45
  • $\begingroup$ Please add new information (like gif, pictures, text) by editing your question, not by posting answers. This a Q&A (Question at top, Answers after), not a track of discussion. $\endgroup$ Commented May 22 at 10:30

3 Answers 3

2
$\begingroup$

(Using Blender 3.6.8)

The approach implemented in the following GN graph is:

  • To trim the curve to make its length proportional to the user-defined spacing (dark red part).
  • To spawn on points instances picked in a collection, as many times as required (dark green part).
  • To spawn on the last point a specific instance (dark blue part).

GN Graph

Setup

1. A BezierCurve is added in Object Mode. In Edit Mode, its control points are "hooked" to three empties, used as manipulating handles. The middle one is animated up and down.
2. In Object Mode, one Cube is added at the world origin, then duplicated. This copy is rotated by 45 degrees around its Z axis, remaining centred at the world origin. Both cubes are gathered in a Collection. These are picked in alphabetical order. So their name is edited to control which one is instanced on even indices (the first one), and which one is instanced on odd indices (the second one).
3. In Object Mode, one Sphere is added at the world origin. (NB: Transformations must be "applied" to these objects (cubes and sphere) to spawn).
4. In Object Mode, one Single Vert is added at the world origin. The GeometryNodes modifier is attached to this object. Its Input are:
4.1. Curve: the curve on which to spawn other objects.
4.2. Last: the object to spawn at the last index.
4.3. Collection: the collection containing the objects duplicated along the curve.
4.4. Count: the number of objects to spawn, excluding the last one (labelled $n$).
4.5. Length: the distance between two successive spawned objects (labelled $\lambda$).

Trimming the curve

1. The Geometry of the input curve is recovered through an Object Info node.
2. Let $L$ be its Length, evaluated with a Curve Length node. It is assumed that $L \ge \lambda$. Let $N$ be an integer such that $N+1$ is the maximum number of points along the curve separated exactly by the length $\lambda$. Let $l$ be a length such that $l \lt \lambda$. $N$ and $l$ are defined by the relation $L = N \lambda + l$.
3. Consequently $N$ is computed as the truncated part of $\frac{L}{\lambda}$.
4. The input curve length is reduced to $N \lambda$ using a Trim Curve node.
5. Eventually, $N+1$ points are interpolated along the trimmed curve with a Curve to Points node set in Count mode. It is returning a Rotation vector per point, which aligns the Z axis of an object with the local tangent to the curve.
6. For subsequent operations, the number of duplicated objects is limited to the Minimum between the user-defined value $n$ and the computed value $N$ to not exceed the length $N\lambda$.

Spawning duplicated objects from collection

1. Duplicated objects are spawned by an Instance on Points node.
2. The Selection of the points sampled along the curve to use is based on a Less Than node comparing these points Index with $n$ (or $N$ if $n \gt N$). As Index value starts at 0, it yields that exactly $n$ points with an Index value in the range $[0,n-1]$ are selected.
3. Individual objects to spawn are picked from a user-defined collection. This behaviour is controlled by the Pick Instance check-box and by the Instance Index socket. As it is left unconnected, the point Index is used to choose which object to spawn. Because there are only two objects in the collection, the first one is used for even indices (starting at 0) while the second one is used for odd indices (starting at 1).
4. Instances are recovered from the collection using a Collection Info node. The Separate Children socket is controlling that only one object at a time is picked, not the whole collection.
5. The Rotation vector output by the Curve to Points node is directly connected to the Rotation input socket to align the Z axis of the spawned object with the local tangent to the curve.

Spawning the last object

1. The last object is spawned by an Instance on Points node, its Geometry being recovered through an Object Info node.
2. The Selection of the point along the curve to use is such that its Index is Equal to $n$ (or $N$ if $n \gt N$). As Index value starts at 0, it means that it is the $(n+1)^\mathrm{th}$ spawned object.
3. No Rotation is applied because it is a sphere.

Resources

$\endgroup$
5
  • $\begingroup$ it works nicely but when I move end point of the curve, mesh moves strangely because of real time curve action? Please see my new gif image which explains what I mean. I need to animate curves using armature bones so can I avoid this movement? $\endgroup$
    – Yokomizo
    Commented May 22 at 9:54
  • $\begingroup$ I uploaded new gif image on my new answer post. please see it. $\endgroup$
    – Yokomizo
    Commented May 22 at 10:02
  • $\begingroup$ it works perfectly. I need time to understand what you did. I will ask you later, is it ok? It's just hard to understand geometry node. $\endgroup$
    – Yokomizo
    Commented May 23 at 0:22
  • $\begingroup$ I check your node. I understand blue and green nodes but I can't understand brown nodes. Why Dive Truncate Multiply nodes are needed? What Trim Curve and Curve to Points nodes did? $\endgroup$
    – Yokomizo
    Commented May 23 at 1:41
  • $\begingroup$ Thank you. I will read them all. $\endgroup$
    – Yokomizo
    Commented May 27 at 16:37
0
$\begingroup$

I tried armature solution and added another curve and Spline IK to move geometry node curve points and keep their distance.

https://i.imgur.com/6IH8WwL.gif

It works sort of but if you know anything better please tell me. Blend file is here.

$\endgroup$
0
$\begingroup$

new gif image for StefLAncien

sphere instance moves back and forth when last curve point comes closer to 2nd curve point.

https://i.imgur.com/vaGMpLW.gif

$\endgroup$

You must log in to answer this question.

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