While trying to a parse a wavefront .obj file, I thought of two approaches:
- Create an 2D array the size of the number of vertices. When a face uses a vertex, get it's coordinates from the array.
- Get the starting position of the vertex list and then when a face uses a vertex, scan the lines until you reach the vertex.
IMO, option 1 will be very memory intensive, but much faster. Since option 2 involves extensive file reading, (and because the number of vertices in most objects becomes very large) this will be much slower, but less memmory intensive.
The question is: Comparing the tradeoff between memory and speed, which option would be better suited to an average computer? And, is there an alternative method?
I plan to use OpenGL along with GLFW to render the object.