ObjLoader Debugging

The OBJ loader you are given loads a valid file, but but fails to provide feedback if the file format is incorrect

Assignment: make every format error explain itself and extend its capability.

1. Quick Start

Download cpp project
cmake -S . -B build && cmake --build build
./build/objloader_tests

You should see 3 of 11 passing, and the run ends in a crash at case 10, missing_uv_data.

All of this is expected.

Two ways to run it:

./build/objloader_tests                                       # run everything
./build/objloader_tests --only test05_face_not_triangle.obj   # one case with full detail

--only <value> takes the exact .obj filename of one of the built-in cases.

2. Files

You should only edit src/objloader.cpp.

Assignment file and test case information
PathContent
src/objloader.cppstarter code
include/objloader.hppAPI and ObjIssue list
src/diagnostics.cppmessage formatting and report printing
tests/test_objloader.cpptest runner
tests/models/test01_... - test11_...test files (see table below)
external/glm/glm headers

3. The 10 Cases

include/objloader.hpp defines 10 ObjIssue this loader can detect.

There are 11 test cases - one per condition, plus one baseline case (strict).

4. Test Files

4.1. Description

Assignment file and test case information
#FileTest caseIssueOutcome required
01test01_strict.objstrict(none - baseline)loads cleanly with 0 diagnostics
02test02_malformed_vertex.objmalformed_vertexMalformedVertexreject
03test03_malformed_texcoord.objmalformed_texcoordMalformedTexCoordreject
04test04_malformed_normal.objmalformed_normalMalformedNormalreject
05test05_face_not_triangle.objface_not_triangleFaceNotTrianglereject
06test06_malformed_face_vertex.objmalformed_face_vertexMalformedFaceVertexreject
07*(no file - path doesn't exist)*file_not_foundFileNotFoundreject
08test08_missing_normal_data.objmissing_normal_dataMissingNormalDataaccept, with warning
09test09_index_out_of_range.objindex_out_of_rangeIndexOutOfRangereject
10test10_missing_uv_data.objmissing_uv_dataMissingUVDataaccept, with warning
11test11_negative_index_unsupported.objnegative_index_unsupportedNegativeIndexUnsupportedreject

4.2 Hints

Assignment file and test case information
FileWhat's inside
test01_strict.objUnit square in the XZ plane, two triangles, facing +Y, full v/vt/vn form.
test02_malformed_vertex.objA v line with only 2 numbers instead of 3, referenced by a face.
test03_malformed_texcoord.objA vt line with only 1 number instead of 2, referenced by a face (v/vt form).
test04_malformed_normal.objA vn line with only 2 numbers instead of 3, referenced by a face (v//vn form).
test05_face_not_triangle.objA square as one 4-vertex face instead of two triangles.
test06_malformed_face_vertex.objA face token with four slash-separated fields.
test08_missing_normal_data.objBare position-only faces with no normal referenced.
test09_index_out_of_range.objThe face cites position 99 in a file that only defines 4 positions.
test10_missing_uv_data.objA face references a uv slot, but the file defines zero vt lines anywhere.
test11_negative_index_unsupported.objEvery face-vertex index is negative. Valid OBJ meaning "counted backward from the most recently defined element," is not implemented here.

The suite checks the ObjIssue value, never your message wording, so phrase detail however you like.