0
$\begingroup$

I'm trying to get sum of all relative positions of adjacent vertices, to use it for offsetting position of curent vertex. By connected vertices i mean sharing same edge. Sounds simple, but i can't really figure it out. Or just any way to check if some vertex is connected to curent vertex?

eg, i want to push all vertices from each other, like scaling every edge, but also changing their direction


Thank you

$\endgroup$
8
  • $\begingroup$ Does this answer your question? How do I average values in a field per ID with Geometry Nodes? By definition, connected vertices form mesh islands, so you can use my setup there to get the average position, or the sum of positions… You can subtract from current position the average position to get the offset to the average position. If there's just 2 vertices in each island, you can subtract from the sum of positions the current position, giving you the other position. $\endgroup$ Aug 16, 2023 at 10:26
  • $\begingroup$ @MarkusvonBroady sorry, by connected vertices i meant sharing same edge, not island $\endgroup$
    – Lipesto
    Aug 16, 2023 at 10:32
  • $\begingroup$ What are you trying to do exactly? Can you show the geometry you want to apply it on and what is the desired result? $\endgroup$ Aug 16, 2023 at 10:54
  • $\begingroup$ @MarkusvonBroady edited my question $\endgroup$
    – Lipesto
    Aug 16, 2023 at 11:29
  • $\begingroup$ the way your question is currently phrased, and with the example provided, my first comment explains how to achieve that: "You can subtract from current position the average position to get the offset to the average position." - then you can use Vector Math: Scale to scale this offset, and pass it to Set Position: Offset. $\endgroup$ Aug 16, 2023 at 11:55

1 Answer 1

1
$\begingroup$

To move a vertex in relation to the average of two connected vertices, you could use "Edges of Vertices" node to select vertices that have two edges (and therefore are the middle vertices), and use this answer:

How do I average values in a field per ID with Geometry Nodes?

Or, using the same selection, you could also use the same node to find the first and the 2nd edge, sum up the positions of their verts, since you summed up 4 verts, divide it by 4 to get an average, and then subtract your own position from the equation - "your" (currently evaluated vertex) position was counted twice, so you would multiply it by 2 first, but since you already divided by 4, you get ${2\over4} = 0.5$, so those are the two values in the Vector Math: Scale nodes below:

The third (right-most) Scale node is there to scale the effect like so:

In case of other attributes than the position, you can't use the "Edge Vertices" node to easily access attributes of both vertices, but you can use (hidden above) indices outputs instead, to sample the values of the vertices, using the same trick of adding both and removing self, but separately for each edge:

$\endgroup$

You must log in to answer this question.

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