Page 1 of 1

Vertex order in JSON

Posted: Wed Sep 02, 2015 8:17 pm
by Achder
Hello,
for my project it is important, that the vertex-order stays the way it is signaled in the editor. But when I export to a json file, the vertex order gets mixed up (it's still ccw, but the "first" vertex is not the first). For clarification: The expected vertex index is the one, that the editor shows me, when I hover over a vertex in vertex mode. Could you please fix this?

Re: Vertex order in JSON

Posted: Thu Sep 03, 2015 6:09 am
by iforce2d
I'll presume you are talking about convex polygons with only 8 sides or less, because a polygon that is either concave or has more than eight vertices would required decomposition into multiple sub-polygons and the vertex order would be different anyway.

All I can suggest is to make a copy of the polygon and set it to be a 'loop' shape so that it does not undergo polygon decomposition during export, and the vertex ordering would be unaffected. After loading the scene into your game you can get the vertices in their original order from this loop shape, and then destroy it.