0

I'm working on .obj importer and I've created a test .obj file in Blender to see if my importer can work with it. Unfortunately, I get out of range exceptions because my model is riddled with vertex indices that are out of range.

For example, in the mesh "Doors" there are 120 vertices, but you can see that down in the submesh, indices that are mentioned are a lot higher (146, 147, 149...).

My .obj file is here. Does anybody know why are these indeces higher than the number of vertices or how to handle that?

  • its either broken wavefront , or using some undocummented extention/behavior (modern coders does this insanity time to time for example see [Animated gif only loops once in Chrome and Firefox](https://stackoverflow.com/a/38082881/2521214) causing us headaches latter on...) loading the mesh ignoring faces with wrong indexes looks fine but did not inspect it closely... – Spektre Mar 22 '22 at 08:20
  • I would guess the vertex number counts all the vertices in the file, not just the ones from that object – user253751 Mar 22 '22 at 12:56
  • Please share any relevant code in the Question, as a [minimal, workable example (mwe)](https://stackoverflow.com/help/minimal-reproducible-example). Not all users will click on links and therefore won't be able to help reproduce, and solve, your issue. – tjheslin1 Mar 24 '22 at 16:20

1 Answers1

0

Ok, I found out the answer. It turns out that submeshes in .obj files index vertex positions, texture coordinates, and normals on a global scale. So vertex at index 156 in submesh of 2nd mesh is 156th vertex counting from the first vertex of the first mesh. I don't know why do they do it like this :(.