February 2019
Intermediate to advanced
292 pages
6h 55m
English
Your OBJ parser is already quite close to supporting smooth triangles. All it needs now is to support the vertex normal (vn) command and to update the way it parses the f (“face”) command.
Vertex normal data should be correctly imported from an OBJ file.
This test sets up an OBJ file that contains four vertex normal statements (“vn”), and then shows that each of them is imported as a vector. Note that the normals collection is 1-based, just as the vertices collection was.
| | Scenario: Vertex normal records |
| | Given file ← a file containing: |
| | """ |
| | vn 0 0 1 |
| | vn 0.707 0 -0.707 |
| | vn 1 2 3 |
| | """ |
| | When parser ← parse_obj_file(file) |
| |
Read now
Unlock full access