2
$\begingroup$

I have a set of lines instanced along a curve using "Replicate Matrix" and "Object Matrix Output."

enter image description here

My goal is to loop through the instanced lines and, for each one, get a random point on it, find the nearest point on the next instanced line, and make edge between them. The end result I want is edges drawn through all of the instanced lines, looking something like this:

enter image description here

I've tried to do the following way. First, a loop that runs through the lines and finds edge starts and ends:

enter image description here

The "random point" comes from the Random Number that inputs to the Get List Element, which has the vertices from the first line. I then pass these edge starts and ends out of the loop to draw the edges.

enter image description here

This works to some extent, but I'm having problems achieving the result I want. The result I actually get is more like this:

enter image description here

Edges are drawn between adjacent lines, but only between the two lines currently being compared in the loop. And the number of edges being drawn between adjacent lines increases as the loop runs. I don't understand why that is. And the edges don't accumulate as the loop runs - so the edges drawn on first iteration aren't preserved in the second, etc.

To try to fix the second, accumulation issue, I tried to make this second loop, which would save all the edges the loop calculates:

enter image description here

But this hasn't worked. The list in the Append gets longer after each iteration, but each element in the list gets written over with a single vector value. You can see that happening, e.g., in the Viewers connected to the Append to List nodes. It's weird.

So, that's where I am. I can't figure out how to turn something like the second drawing into something more like the first. Maybe I'm going about this whole thing the wrong way! But even just figuring out how to get the Append node to hold values across iterations would be awesome.

Here's the .blend file:

$\endgroup$
  • $\begingroup$ What do you mean by "get a random vertex", a vertex from where? Can you make a simple illustration to illustrate what your inputs are and what the output is expected to be? $\endgroup$ – Omar Emara Mar 24 '18 at 16:34
  • $\begingroup$ Thanks so much for responding! I made some big edits to the question, which I hope make things clearer, both what I'm after and how I'm trying to get it. Please let me know if I should provide more info. $\endgroup$ – Chris Mar 24 '18 at 18:02
  • $\begingroup$ I think uploading your blend file could help... Imagine people trying to understand your nodes just reading them without knowing exactly which part is connected to which from an image to another... you can upload your file here blend-exchange.giantcowfilms.com $\endgroup$ – lemon Mar 24 '18 at 18:15
  • $\begingroup$ Thank you! I uploaded the file -- I didn't know how to do that. $\endgroup$ – Chris Mar 24 '18 at 18:52
  • $\begingroup$ Are your "lines" just line segments? I mean, are they parallel to each other and flat as you illustrated or are they just line-like meshes? $\endgroup$ – Omar Emara Mar 24 '18 at 18:53
0
$\begingroup$

A spiral or a helix is described using the set of parametric equations as follows:

$$ \begin{aligned} x &= R\cos{t}\\ y &= R\sin{t}\\ z &= \delta t \end{aligned} $$

Where $R$ is the radius, and $\delta$ is the vertical frequency of the curve. By implementing this, we get:

Helix

Now, we are going to move the points of the helix with a random amount in the direction of your choice, I can see you are offsetting them in the direction of the $x$ axis (This is the equivalent of sampling a random vertex along your instanced paths), so lets do that:

Random Offset

The points we just computed act as the first vertex of each edge, the other vertex can be computed mathematically or just by using the Project Point On Line node, the line starts are defined as the position of the next point and the ends are defined as the position of the next point plus some value in $x$ just to define the direction. To the location of the points of the next points, we simply shift the vector list backward, by doing so, each point is aligned with the one following it. Then we create the edges from the points and their projection. The node tree is as follows:

Project

And the result is as expected (The horizontal lines are just for visual aid, not part of the implementation and they are the lines you originally had in your file):

Result

You may notice that there is an extra edge going from the last vertex to the x axis, this is due to the fact that after shifting, the first vector became aligned with the last, and this is just a normal consequent of doing so. To fix that, just remove the last vector and last edge from the output using the slice or remove list element node.

$\endgroup$
  • $\begingroup$ Wow -- thank you! I've got this working, but I'm still studying it. Conceptually, the work of the Shift node is hardest thing to get my head around, but I have some sense of it. One big problem I'm having is the Project Point node. Yours seems to accept a Vector List, while mine only accepts Vectors. So I have to step through the spiral vector list to generate the edges, and so I have the problem of getting edges only between adjacent points. Am I missing something there? Is the Project Point node that accepts vector lists only in the newer version? I have another question... $\endgroup$ – Chris Mar 24 '18 at 20:26
  • $\begingroup$ Which is: if I wanted to find the second vertex of each on another line or shape, rather than just in any old direction as defined by the Vector Math node, I would put the vertices of other other line or shape into the Line End in the Project Point node, right? $\endgroup$ – Chris Mar 24 '18 at 20:28
  • $\begingroup$ @Chris Yes, the Project Point On Line was vectorized in the new version I am using. So you have to create a loop for that node (A loop that only contains the node). I am not sure what you mean by the second question. Can you elaborate on that? $\endgroup$ – Omar Emara Mar 25 '18 at 13:56
  • $\begingroup$ OK great -- this gets to the heart of my question. So I got the edges drawn. When I plug the various vectors into a loop as iterators, then I get all the edges at once. When I plug them into the loop as parameters, I can iterate through the loop and draw each edge individually. And the edges "accumulate" in the way I'm looking for: a new edge each iteration, between adjacent vertices, and edges drawn on previous iterations are still there. But this leads to the second question... $\endgroup$ – Chris Mar 25 '18 at 15:20
  • $\begingroup$ My original goal was not necessarily to draw an edge at every vertex in a spiral, but to draw edges between, e.g., adjacent lines instanced on the vertices of that spiral. That's why I was using the Object Matrix Output node, Object Mesh Data node, etc. But when I try to use the current solution in this way, I get my original problematic result. I can't get edges between adjacent instanced shapes to "accumulate" in the same way. I have the sense I need another loop for that, but I don't know how to do it. (Is this too much discussion for comments?? Should I ask another question?) $\endgroup$ – Chris Mar 25 '18 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.