10

I'm trying to create a row of street lights, both the lamp pole and a spot light. Since i can't simply join these two and use an array + curve modifier to set this up (using an array modifier + a curve modifier always deforms the mesh) so i came to the conclusion that working with collections and instances would be my best bet.

To get to my current result i parented the spot to the lamp mesh. Then i parented those two objects to a plane. after that i parented the plane (and so also the lamp mesh and the spot) to a curve that i converted to a mesh. I then activated Instancing for the curve with verts which resulted in something like this:

enter image description here

As you can see the lamps all face the same direction, while i want them to be rotated inwards. There's an option for 'aligning the objects to vertex normal'

enter image description here

but enabling this exposes a multitude of problems:

  • Problem 1: it turns out there's two instances of every object. (i have no idea why)
  • Problem 2: the street light meshes get deformed.

enter image description here

  • Problem 3: the actual lights all face toward the same place

(I drew over the lamp directions with blue arrows for visibility)

If anyone knows how i can get this to work i'd really appreciate it, but other techniques are welcome too.

Robin Betts
  • 76,260
  • 8
  • 77
  • 190
Felix
  • 103
  • 4

1 Answers1

12

V3.1+

With Geometry Nodes and 3.1 version you can use the Curve to Points and Instance on Points nodes to instance lampposts along any 3D curve.

You'll have to do a bit of trigonometry to rotate the lampposts correctly but you don't have to understand any of it. Just plug the Tangent output from the Curve to Points node, multiply it by $(1, 1, 0)$ to ensure the posts are vertical, and plug it into the Vector input of a Align Euler to Vector node, and plug into the Rotation input of the Instance on Points node.

First place all your lamp post objects in a collection :

enter image description here

Here's the node tree :

enter image description here

Here's a quad view of the result :

enter image description here

V3.1-

You can do it by using an array + curve modifier, you just need to use the plane as an instancer.

Select the plane, add an array modifier and set the length to "fit curve", and set your curve. Add a curve modifier, set it to your curve again. Make sure to parent the lamp post to your plane, then go to the plane's object properties and select "Faces instancing". Here you go : enter image description here

Note that this will not work well if you use a 3D curve.

How to tweak the workflow for a 3D curve :

Instead of using a simple plane for the array + curve combo, use an elongated plane in the Y axis.

enter image description here

Then after the Array and Curve modifiers, add a Weld modifier and tweak the distance until the vertices in the local X axis merge. You should now have a series of segments, with both vertices of each segment on the same XY plane. These segments follow the 2D curvature of the curve object.

enter image description here

Add a Screw modifier on the X axis, set the angle to 0°, the steps to 1 and the screw property to a small value.

enter image description here

Now enable instancing on faces.

enter image description here

Gorgious
  • 30,723
  • 2
  • 44
  • 101
  • Hello Gorgious; so do you have any idea how it would be possible to do it with a 3D curve in the latest versions? I was wondering if geometry nodes could solve the problem – moonboots Jan 20 '21 at 07:24
  • @moonboots I don't think one can access curve control points in geometry nodes yet, I updated the answer for a workflow that might possibly work for 3D. It has its shortcomings though for extreme curvatures and when the curvature inverts... – Gorgious Jan 20 '21 at 08:01
  • Ok thaks, I'm going to study that, I hope they will come with a simpler solution ;) – moonboots Jan 20 '21 at 08:03
  • I hope so too ! I think this will get solved sooner rather than later, seeing at which pace they are adding new features for instancing :) – Gorgious Jan 20 '21 at 08:06
  • 1
    Haha Thanks Robin !! I sure hope there is an obvious solution we just keep missing >< – Gorgious Jan 29 '21 at 21:38
  • 1
    Looks like no takers... If there's a better way, I can't find it :) Recently, I had to go back to this answer of yours to do it at all . It seems ridiculous to have to twist yourself into a pretzel to do something so commonplace. Nonetheless, I'm very grateful for your ingenuity! And I'm sure others will be, too, until Everything Nodes or somesuch fixes it. I guess there must be an AN answer, but it should be native, really. – Robin Betts Feb 04 '21 at 17:11
  • That was impressive!! – Chris Jun 21 '21 at 06:05
  • Gorgious, I've tried your method but with a simple edge and with Array + Curve + Screw (with curve having the Twist Method > Z-Up) and it seems to work, what about this method that seems simpler, does it have a drawback? Actually your Weld just makes an edge, isn't it? So why not beginning with an edge? – moonboots Jul 12 '21 at 16:43
  • @moonboots Yes that's an oversight on my part :) it actually removes one step with your method – Gorgious Jul 12 '21 at 16:46
  • 1
    great I had a big doubt ;) I wanted to make a tutorial about the different methods of duplicating along a curve, I will cite you of course – moonboots Jul 12 '21 at 16:49
  • @moonboots Good idea :) I didn't test it but I'm sure the new 3.0 GN toolset can help achieve it in a less clunky way. Love your channel btw great content ;) – Gorgious Jul 12 '21 at 18:27
  • Thanks! Can you use curves in the GN? – moonboots Jul 12 '21 at 18:29
  • @moonboots Yes ! It's a bit dated now but you can watch https://www.youtube.com/watch?v=m_IHcJ1vwgE – Gorgious Jul 12 '21 at 18:33
  • 1
    well I think your method is pretty easy so I will stick with it ;) but yes one day I will need to learn GN – moonboots Jul 12 '21 at 18:36
  • You lose me when you say "both vertices of each segment on the same XY plane" - none of my four vertices are in the same xy plane before I set my weld modifier. – Alex Safayan Oct 30 '21 at 01:35