3
$\begingroup$

TLDR: I need to randomly rotate meshes within an object individually (based on their individual origins), using Geo nodes.

We now have a "Scale Elements" Node in Geometry Nodes that will take separate parts of a mesh and scale each according to a value that you choose. What I am trying to do is very similar to this node but instead of scaling I want to individually rotate the different parts of a mesh that are separate from one another. The separate meshes of the same object might be described as "Mesh Islands". The Mesh Island node seems confirm this as it indexes each of my rock meshes as a separate 'island'.

The ability to rotate mesh islands individually would be very useful in my project where I want to make a procedural "tilled earth" generator, where clods/chunks of earth will naturally be found at different angles but also be somewhat flat looking on one side most of the time (think like a clay-rich soil broken up roughly).

The tutorial I'm working from to achieve the foundation of my node system is this one on Youtube by Default Cube:
Turning ANYTHING into Rocks - Blender Geometry Nodes

What I have so far:

Rocks generated from grid using Geo-Nodes

My Node Tree (similar to one seen in video- not exact):

Procedural Rocks Node Tree part1

Procedural Rocks Node Tree part2

Procedural Rocks Node Tree part3 End of Node Tree

I have a feeling I'm overlooking something very basic here. Seems like a foundational technique that should be simple to achieve? After all it's just rotation individual parts of an object, easy to do outside of geometry nodes.

$\endgroup$

2 Answers 2

4
$\begingroup$

I didn't look at your file, since I wrote the answer before you published it, but a solution might look something like this:

enter image description here

The trick here is to find the center of rotation of a mesh island.

There are probably other ways, but this solution still works quite well.

Here I first accumulate the positions of the points that are connected with faces (the mesh islands).

Then I scale the accumulated vector with the value $1/numberOfPointsPerMeshIsland$, and get a mean value, which serves me as center for Vector Rotate.


(Blender 3.2+)

$\endgroup$
3
  • $\begingroup$ Just wanted to confirm that this works flawlessly for me, thanks! Will be using this or Kuboa's method until they create something like a "Rotate Elements" Node. Hats off to both of you. $\endgroup$
    – Xfacter
    Nov 21, 2022 at 18:57
  • $\begingroup$ I've been working through your solution a bit trying to understand what's happening and still can't figure out what exactly the scale vector scale node is doing. When I disconnect it or bypass the rocks go flying everywhere. I'm assuming it's because their 'center point' is way far off for each rock but I still can't figure out why it would be that way assuming the first accumulate field node is doing the job of outputting each origin point of every mesh island in the index? $\endgroup$
    – Xfacter
    Nov 22, 2022 at 15:10
  • $\begingroup$ @Xfacter Assume you have the vector $(1, 1, 0)$. If you scale it by $0.5$, you get the vector $(0.5, 0.5, 0)$. This is multiplied by $0.5$, but still points in the same direction. In this case I multiply the sum of all vectors (positions) of an island with the value which results from $1/numberOfPointsPerMeshIsland$. This gives me the mean value, which corresponds to the mean position of the mesh island. $\endgroup$
    – quellenform
    Nov 22, 2022 at 15:20
2
$\begingroup$

Quellenform's answer is better, more fool-proof, but if like me you're no good at math, here's a more brute-force method. We need the individual 'origin's of the mesh islands, so first I collapse them into their centers, using a Merge by Distance. If we use the default All mode, they'll all collapse into one single point for the whole mesh, so we use the Connected mode instead:

Then, using a Sample Index node (before 3.4, Transfer Attribute) we capture the positions of these points by their Island Index to feed the Center socket of a Vector Rotate node:

enter image description here

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ I tried this method too and it also worked. Just a word of advice to anyone in the future using the Transfer Attribute node like I did: The three options from the drop down menus that you need are: Vector, Index and Point. Then plug the Position node into the 'Attribute' port and Mesh Island Index into 'Index' port. Also I almost forgot to set Merge by Distance to Connected. Thanks for writing that explicitly Kuboa otherwise I might have overlooked it. Very much appreciate that and the gifs :) $\endgroup$
    – Xfacter
    Nov 21, 2022 at 19:05

You must log in to answer this question.

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