Hey, I was able to successfully import a level using sm64Import 0.1, but I had to make some changes to get it to work. First, when I tried to run sm64Import.exe from your build, it crashed with my inputs. I am not sure what went wrong, but it could be related to some weird values in my .obj file (see stof() info below). The crash details are:
Some of the changes I had to make were just due to building with gcc or running on Linux. I'm attaching my updated source.cpp (renamed source.txt for forum) with all the changes I made and a Makefile (renamed Makefile.txt). A description of the changes follows below. Let me know if you have any questions or prefer a pull request on github for these changes.
getline:
getline() works great if you are using text files created on the platform you are running this code, however, it keeps the '\r' in Windows text files in the string when run on a platform that uses different line endings, which causes things like the mtllib filename and texture filenames to keep the '\r' at the end and open() fails (isn't C++ fun?). I used one of the solutions from here:
http://stackoverflow.com/questions/6089231
byteswap:
_byteswap_ushort()/_byteswap_ulong() are specific to MSVC. GCC and clang have their own variety. I added some ifdefs and defines for these, but I think the application still might be wrong. For example, if sm64Import were to be built on a system that is already big endian, it would be swapping to little endian. I prefer to keep integers as native endian and then explicitly pack them as big endian in byte arrays.
stof:
I didn't even know this could be a problem until it died on a .obj file that Sketchup produced. I am pretty sure it is because of the really small float values (practically zero) that Sketchup likes to use for vertex normals (e.g. "vn 4.6208e-032 1 -7.08593e-033")
terminate called after throwing an instance of 'std::out_of_range'
what(): stof
I just converted them all to stod() and let the implicit casts do their thing.
c_str():
Most of the printf()s have this, except the error message at the end and some commented out debug along the way. I went ahead and added it there, otherwise you get garbage output.
sprintf:
I expanded some of the sprintf()s to use %02X instead of %X just to make them nicer for debugging. I would recommend adding a debug flag that can be passed in the command line and uncomment all the printf() debug statements so if you run into trouble with a released build, you can see how far it is getting and where it is choking up.