Fast C OBJ parser
Find a file
Arseny Kapoulkine 33e0ee7162 Trim trailing whitespace for names
Some .obj files have extra whitespace after usemtl and other statements;
this may interfere with parsing, for example by adding a space to the
material name which can result in inability to find it in .mtl file.

For consistency, we replace all uses of is_end_of_name with skip_name
that handles this by leaving trailing whitespace alone. It will be
skipped in the parsing flow when we skip the newline, which is similar
to the behavior of trailing whitespace after numeric data (which
parse_float/int leave alone).
2023-08-13 10:08:29 -07:00
test Merge all face/index arrays together 2019-06-11 07:35:30 -07:00
.gitignore Add .gitignore file 2019-05-19 09:51:43 +01:00
CMakeLists.txt Update CMake file so it can be used with FetchContent in other projects 2021-08-01 14:06:21 +01:00
fast_obj.c Add fast_obj.c to allow compilation as standalone library if required 2020-05-23 16:25:05 +01:00
fast_obj.h Trim trailing whitespace for names 2023-08-13 10:08:29 -07:00
LICENSE Initial commit 2018-07-29 13:31:09 +01:00
README.md Attempt to clarify use of dummy entry in position/normal/texture coordinate arrays 2020-02-29 15:01:22 +00:00

fast_obj

Because the world needs another OBJ loader. Single header library, should compile without warnings in both C89 or C++. Much faster (5-10x) than other libraries tested.

To use:

 fastObjMesh* mesh = fast_obj_read("path/to/objfile.obj");

 ...do stuff with mesh...

 fast_obj_destroy(mesh);

Note that valid indices in the fastObjMesh::indices array start from 1. A dummy position, normal and texture coordinate are added to the corresponding fastObjMesh arrays at element 0 and then an index of 0 is used to indicate that attribute is not present at the vertex. This means that users can avoid the need to test for non-present data if required as the vertices will still reference a valid entry in the mesh arrays.

A simple test app is provided to compare speed against tinyobjloader and check output matches.