How to reverse edge
-
Hello all,
I have selected a array of edges that are all connected
edge1 from point A to B
edge2 from point B to C
edge3 from point D to C
edge4 from point D to AI like to change the edge3.end and edge3.start so edge3 is going from point C to D.
I tried with reverse! and manually changing the edge3.end.position.x Y and z coordinates, but this doesnt work.
I hope somebody can help me out.
Background: I need to change the direction because in the rest of the code I animate something along these edges. If the 3rd edge is as it is now, animation is not OK.
-
If it's a curve its vertices are returned in order, if it's a loop around a face ditto, so there's no need to 'sort' them ?
However, assuming we can't do that...
If you make the pairs of points (as[start.position, end.position]
) into arrays you can match them and reverse them if needed - the 'hash' of the edges...
edge1=[pA, pB] edge2=[pB, pC] edge3=[pD, pC] edge4=[pD, pA]
Take first one 'edge1
', we know that its 'points
' array -points[0]
ispA
andpoints[1]
ispB
.
Next we iterate through the rest of the hash and see if each item'spoints[0]==pB
, if so be break the iteration as that's the next edge to use.
If there's no match we know that maybe the next line's points are 'backwards', so we re-iterate the rest of the hash and this time see if item'spoints[1]==pB
, if so be break the iteration as that is the next edge to use. In this example the 'edge3
' points array is backwards and so it needs to be 'reversed' - usingpoints.reverse!
and thenpoints[0]
ispC
andpoints[1]
ispD
...
It there's still no match we have a line with no next line [an 'end']... -
If your edge is a line you can make
menu edit / group it
a rotation of 180Β° by the middle
explodesorry i have not seen that i was in section developer
-
You want a sorting routine for connected edges?
I got one on disk at home - but I'm currently in Germany on a field trip...
Advertisement