-
assimp
The official Open-Asset-Importer-Library Repository. Loads 40+ 3D-file-formats into one unified and clean data structure.
Curiously, what people commonly refer to as 'Waterfront OBJ' is merely a tiny subset of that format dealing with polygons.
The format supports e.g. higher order curves and surfaces and apps like Maya or Rhino3D can read and write OBj files containing such data. [1]
Writing a parser for the polygon subset also comes with some caveats.
If your target is a GPU you probably need to care for robust triangulation of n-gons and making per-face-per-vertex data per-vertex on disconnected triangles.
Vice versa, if you are feeding data to an offline renderer you want to absolutely preserves such information.
I believe the tobj Rust crate is one of the few OBJ importers that handles all edge cases. [2] If you think it doesn't, let me know and I will fix that.
This is surprising for people familiar with one but not the other of the requirements of offline- or GPU rendering.
I.e. if you write an OBJ reader this can become an issue, see e.g. an issue I opened here [3].
1. https://paulbourke.net/dataformats/obj/
2. https://docs.rs/tobj/latest/tobj/struct.LoadOptions.html
3. https://github.com/assimp/assimp/issues/3677
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
-
-
Note that there's a great C99/C++ single header library, tinyobjloader, that provides robust (in my experience) and feature-full OBJ loading, including triangulation of n-gons and full material parsing.
https://github.com/tinyobjloader/tinyobjloader
It's fairly mature and handles many of the parsing footguns you'll inevitably run into trying to write your own OBJ parser.
-
Thanks!
I had a look at the code and it looked distinctly like C++, but it turns out there is a C version [1] too. Haven't looked into it further.
[1]: https://github.com/syoyo/tinyobjloader-c