There was demand from some students to have an object model loader in C++ and I was trying it since so many days.
The one I am posting is incomplete. It has some issues such as elephant and teddy not loaded properly.
As you can see when I plot each vertex in the object model it seems fine:
But when I draw the triangles It comes with holes.
As shown here:
The model must be incomplete or the program has some bugs, I am not sure what is going on. If anyone could point out the flaw its hugely welcome. On further probing I found that the error seems to be while parsing the input .OBJ file. Certain files have two white spaces between f and the vertex index and some files have an extra blank at the end of each line. I have worked with same files in JAVA and there because of robust string handling functions these minor hiccups do not arise.
Here is the
code in C++.