I have a mesh that is “completely ok” in the sense that the vertices positions and normals directions are all correct. But the sequence in which each faces vertices are defined are somewhat random (see yellow arrows pointing in different directions).
This is usually no problem, but I tried Pufferfish “TwistedBox Mesh” on this mesh and consequently get a messy output.
So the question is: Is there a clever way to rebuild the mesh keeping everything like it is except changing and aligning the sequence of the vertices?
‘MeshDirection’ does what you’re describing when it is possible. It shifts the vertex ordering to match between adjacent faces.
However, this is only possible when a mesh has all even valence vertices. When there’s a vertex surrounded by an odd number of faces (like the 4 around the base of your mesh), they can’t possibly match.
What you could do here is separate it into 2 parts like this (You don’t need to actually separate them in space - I’ve only done that for illustration here, just extract the faces), so neither has odd valence verts, then unify the directions of each
Seems I went a bit too fast and just noticed that after using MeshDirections some of the vertices sequences are correctly oriented but “flipped” (yellow vs. cyan arrows):
Yes, MeshDirection only matches directions up to a flip - i.e. the vector from vert 0 to 1 of a face will never be perpendicular between adjacent faces, but it can be antiparallel.
The original application it was made for was sorting curvature aligned quad meshes, which usually have vertices of valence 2/4/6
To make edges match fully without reversals would mean it could only work on meshes with all vertex valences a multiple of 4 which is rather restrictive.
I can see that for some cases like things that are topologically simple tubes or planes it might be useful though, and I could modify the script for this.
However, in the case where you know you want 0-1 to point upwards, things can be a bit simpler, like this:
I can see that for some cases like things that are topologically simple tubes or planes it might be useful though, and I could modify the script for this.
You mean changing the ‘MeshDirection’ component? I think me and probably many others would appreciate that. And - from what I can guess - this should not do harm to existing projects using this component.
However, if you do so, maybe consider implementing some way to “rotate” the mesh vertices. I tried doing this with an offset of the list item - and in my case it works great. But maybe there is already a better way to do this. Here is what I mean:
As this is similar to what ‘MeshTurn’ does, it would probably be an idea to give MeshTurn a second input to enable more control to turn x time 90 degrees with input being 0 to 3.