I completed feature number 1, which was loading an OBJ mesh into my scene. Essentially, I took Chris’s code from lecture, but changed it so that the obj file doesn’t have to be manually altered in order to work correctly (counting the vertex and face lines and putting the totals in the file). Now, my code first loops through the whole file counting all of the vertices and faces (lines beginning with ‘v ‘ and ‘f ‘ respectively), and then re-loops through the file and reads in the vertex and face data. These edits involved a little bit of research into parsing strings in C++, so I referenced the C++ documentation and found “strtok” to use to split the vertex and face lines on the spaces.
Once I got this code working, I modeled a goal post in Blender to read in as my object. However, even though I had joined all of the components in Blender before I exported, the goal post still shaded strangely in my scene. Chris’s most recent lecture revealed my fix: the normals weren’t calculating correctly due to shared vertices, so all I needed to do was add the “Edge Split” modifier to my model. When I re-exported with the applied modifier, it shaded much better:
Here is a very short video showing my model in my scene: (Sorry, it’s shaky because I did it on my camera, and I don’t talk because I was in the lab and there was other people in there too!)