4 ms·
Curiously, what people commonly refer to as 'Waterfront OBJ' is merely a tiny subset of that format. I.e. the part dealing with polygons. The format supports e
by virtualritz 2y ago
Curiously, what people commonly refer to as 'Waterfront OBJ' is merely a tiny subset of that format. I.e. the part 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 a challenge; see e.g. an issue I opened here [3].
1. https://paulbourke.net/dataformats/obj/ https://paulbourke.net/dataformats/obj/
2. https://docs.rs/tobj/latest/tobj/struct.LoadOptions.html https://docs.rs/tobj/latest/tobj/struct.LoadOptions.html
3. https://github.com/assimp/assimp/issues/3677 https://github.com/assimp/assimp/issues/3677
- grandempire 2y ago> robust triangulation of n-gons and making per-face-per-vertex data per-vertex on disconnected triangles. This is a simple post-process step after parsing.
- sreekotay 2y agoDepends on your definition of robust (e.g. how are you handling T-junctions) but in general I would agree with this, in that that some things that are NOT trivial should rightly be pushed up the art pipeline. Good pipelines shouldn't rely on clever parser behaviour (as a general rule)
- grandempire 2y agoGood point about T-junctions. I was thinking only of combinatorial triangulation.
- virtualritz 2y agoWhen your polygons are convex and non-planar 'simple' quickly becomes an euphemism. You may even want to consider adjacent topology for something as 'simple' as which of two possible solutions to take, when splitting a non-planar quad into two triangles. Triangulation is simple only when your polygons are planar and convex and aspect ratios of resulting triangles do not matter under any 2ndary circumstances. Some uses e.g. require avoiding thin, splinter-like triangles.
- the__alchemist 2y agoHow does this compare to the `obj` crate? I'm assuming that doesn't handle cases beyond the common one well? I ask because I have a 3D rendering/GUI application lib in rust (`graphics` crate), and for OBJ files, I thinly wrap that to turn it into a mesh. In my own applications, it hasn't come up, as I've been mostly using primitives and dynamically-generated meshes, but am wondering if I should switch.