0
$\begingroup$

I make a Lego model using Geometry Nodes from this tutorial: https://www.youtube.com/watch?v=LrEHoaq6QFE.

enter image description here

But now all the legos have the same rotation and face in 1 direction. If I want the Lego rotate followed the face normal (like the egg below). Do you guys know how to do it ??? (Lego limits by the 90-degree rotation, can't rotate freely)

enter image description here

$\endgroup$
2
  • $\begingroup$ You could probably do this with proximity. For each box you have find the closest face of the original geometry. Get normal of that face. Compare it with the list of the 6 directional vectors you want and find the closest. Finally rotate each box so that top is in the direction of this vector. This is of course gonna be just visual and it won't give you a way to reconstruct it with real lego bricks $\endgroup$ Apr 14, 2023 at 11:13
  • $\begingroup$ Can you give me the image of the geometry nodes? It really hard to understand. $\endgroup$
    – Iampoor
    Apr 14, 2023 at 11:31

2 Answers 2

1
$\begingroup$

Ok I recreated my answer from the comment and made some screenshots so that you can Follow. What you need to do is find the closest face of the original geometry to each center point of the instances. This can be done by 'sample nearest' node and pluging 'position' node to sample position socket. The output of this node is an index of the closest face for each center point of instance.

enter image description here

After that you need to retrieve the normal attribute from the original geometry for each center point of the instances based on the index you retrieved in previous step.

enter image description here

And finally you need to align the z vector of the instanced geometry to the normal of the closest face and rotate the instance by it. This will give you this result which is exactly what you are asking for:

enter image description here

Now the thing is - like this it will work only for ortoghonal original geometry (as the normals are always facing the 6 directions you want). To make it work for any geometry you have two ways to go. Either Voxelise the original geometry before applying the geometry nodes. (remesh modifier -> Blocks) This way the normals are always gonna be within the bounds you want. Or you can compare the new normals to the 6 directional vectors you want, find the closest one for each normal and use it instead of it.

$\endgroup$
1
  • $\begingroup$ I'd also recommend to delete points that are inside of the geometry before putting instances on them so that blender doesn't have to calculate with them (they are not visible anyway) $\endgroup$ Apr 14, 2023 at 13:54
0
$\begingroup$

Thanks a lot for Jiří Honzák answer. And to be honest, I have used the simple way by using "Sample Nearest Surface" Nodes.

enter image description here

But your last sentence is what I really looking for: " Voxelise the original geometry before applying the geometry nodes. (remesh modifier -> Blocks)".

Thanks a lot bro

$\endgroup$

You must log in to answer this question.

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