I'm new to Blender, but I've used Max & Maya in the past, both of which I've never had this problem with.

The issue I'm having is when exporting a simple mesh as .obj the vertex ordering is all messed up. I have tried sorting the vertices using the Sort Elements in the Mesh menu but it is not working as expected, see below...

v -10.000000 5.000000 0.000000 
v -10.000000 6.000000 0.000000    
v -10.000000 7.000000 0.000000    
v -10.000000 8.000000 0.000000    
v -10.000000 9.000000 0.000000    
v -10.000000 10.000000 0.000000    
v -10.000000 -2.000000 0.000000    
v -10.000000 1.000000 0.000000    
v -10.000000 -1.000000 0.000000    
v -10.000000 2.000000 0.000000    
v -10.000000 3.000000 0.000000    
v -10.000000 4.000000 0.000000    
v -10.000000 0.000000 0.000000

As can be seen the ordering is jumping all over the place instead of sorting properly. I have tried with 'Keep Vertex Order' and without, it makes no difference.

The only way I can get the sorting to work properly is if I select each Vertex individually and sort it using Selection on that one Vertex to push it to the front, then select the next, repeat, etc.. Obviously this is a ridiculous way of doing it and will take a very long time!! Am I missing something here, as it seems to me that the sorting is broken?

Is there a way that I can write my own script or rewrite the current sort script to sort the Vertices properly from within Blender, Or am I going to have to write a program to parse through the .obj afterwards to fix this? i.e. ascending X, then ascending Y, like this...

v -10 -10 0
v -10 -9 0
v -10 -8 0
v -10 -7 0
v -9 -10 0
v -9 -9 0


Reason for this being to read the .obj and create a continuous triangle strip for rendering which, in the current format, is impossible without sorting first.

I have searched many forums and found a few similar cases, but with no answers, at least none that have understood the question.

I should point out that the mesh is a plane, x & y coords all at integer values, basically a grid. It's a basic floor mesh!


closed as off-topic by iKlsR Oct 19 '14 at 20:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is too localized in its current form and is unlikely to be applicable outside of a very narrow context. Consider broadening the scope of this question in order to make it more useful for future users of the site." – iKlsR
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ The strange thing is that a software depends on the sorting order of the vertices, and sure you could create your own export script to do this. $\endgroup$ – stacker Oct 19 '14 at 16:24
  • $\begingroup$ It doesn't matter what the mesh is... the obj format is correct and is universal. You don't need to worry how blender or other programs sort their vertices... after all that is why you have the universal obj file format. When you export an obj you have the lines which start with 'f', they describe the ordering of the vertices which make up each face. That is how you would find the order that you need... you cannot and shouldn't rely on the ordering of the verts, as each program could vary in the way they store its mesh verts internally, which results in undefined behaviour. $\endgroup$ – G.Rassovsky Oct 19 '14 at 18:41
  • $\begingroup$ G.Rassovsky... I understand the idea of using faces to sort vertices, unfortunately the faces aren’t in order either! The first face starts at a random spot, and the following faces don’t seem to follow a logical sequence, just random. This still leaves me with the issue of needing to resort the data so that I can build a continuous triangle strip for rendering. If I were to just draw triangle primitives, or a separate triangle strip for each quad then this would be fine. I have tried exporting to other formats which gives the same random sorting.... $\endgroup$ – Craig S Oct 19 '14 at 19:11
  • $\begingroup$ ... So the problem is not with exported file format but that sort in Blender doesn’t seem to be working to a logical format! Without a logical ordering finding neighbours, etc… won’t be possible without sorting first; a problem that other programs I’ve used didn’t create. Thank you for your response. $\endgroup$ – Craig S Oct 19 '14 at 19:11
  • $\begingroup$ On the one hand, this is very important to anyone who is exporting for a game engine since the proper ordering will determine how much of a model can fit into the GPU's cache memory at any given time and this can have a big impact on performance since redundant calculations have to be re-calculated for overlapping vertices which don't make it into the cache with the others. On the other hand, this may only be solvable by core BF devs since it relates to how Blender is sorting primitives; for this last reason, I do think this is better discussed on irc.freenode.net #blendercoders $\endgroup$ – MarcClintDion Oct 19 '14 at 21:19

partly solved!! (see comments below)

OK then....

Just updated Blender from 2.71 to 2.72.... everything works as it should now, weird!! The vertices and faces are sorted properly.

Had 2.71 on PC and laptop, still got 2.71 on PC and it doesn't sort the vertices properly, now that I've updated laptop to 2.72 that works fine!!

Some weird bug that they've fixed? Either way, I'm good now.

Thank you stacker and G.Rassovsky for your responses.

  • $\begingroup$ OK, so the mesh faces still don’t sort properly… they nearly do, but there’s the odd case of it picking faces out of sequence. So is this a problem with the algorithm used in the Blender sort, or am I missing something? $\endgroup$ – Craig S Oct 19 '14 at 20:51
  • $\begingroup$ I’m confused as to why this question has been put on hold! The whole point of asking a question is to find a solution to the problem that I am facing. Yes, it’s a very narrow context, the narrow context that I’m having a problem with! If every question that isn’t scoped wide enough for someone else is put on hold then no questions would ever get answered!! The fact remains that I am having a problem that I have come on here to ask about… how is putting it on hold helpful? If you have a suggestion for me then please state it, rather than just blocking it. Thank you $\endgroup$ – Craig S Oct 19 '14 at 20:52
  • $\begingroup$ ... Have I put this question in the wrong section of the site? In which case please advise as to which section it should be in. $\endgroup$ – Craig S Oct 19 '14 at 20:54
  • $\begingroup$ From Help Center "What topics can I ask about here? The Blender Stack Exchange site is for people who use Blender to create 3D graphics, animations, or games." I’m trying to create a 3D graphic for a game, but the sorting of the vertices (now working) and the faces (still issues) needs additional external sorting as the inbuilt Blender sorting is throwing up randoms. I have not had this problem with Max or Maya, just with Blender. So how is this question off-topic, please explain and direct me to make it on-topic so that myself, and any others can get some informed feedback. Thank you. $\endgroup$ – Craig S Oct 19 '14 at 20:55
  • $\begingroup$ I closed as offtopic because the "accepted" solution is not a definite one and the cause was probably a bug that was fixed. Either way, it was not reproducible on my end and seeing as the problem went away with a different version, I would class it as localized. Having a question closed isn't the end of the world, it just means (in this specific) context that this is a special case which has been resolved by the asker, no more answers are required. If you think this is still unfair, you are free to post on our meta site so the community can decide. $\endgroup$ – iKlsR Oct 19 '14 at 21:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.