Switching formats

So I’m doing 3D coding for quite some time now (over 6 years afair, at least with OpenGL) and the only 3D file format I’ve used in all those years was the 3DS - format, which is still widely used (due to the fact that almost every 3D modeller can export/import it and there are plenty of loader) but by nowadays standards totally out-dated.

And due to it’s age this format has some drawbacks that recently made me want to get rid of it. The 8.3 file-naming convention for textures is something I can live with, and the 65k vertices limit per mesh too (if a mesh get’s too big, you can easily split it). But one thing I always hated was the fact that the 3DS format doesn’t store normals and also has no way of saving multiple texture coordinates per vertex. Especially the first one is something that annoyed me, and even when computing normals yourself with the use of the stored smoothing groups, you usually won’t get the same normals as in your 3D modeller, and depending on the mesh it sometimes still looks totally wrong.

So yesterday I finally (one of the main reasons for using 3DS for so long : Pure lazyness, writing an importer for a full 3D format is neither simple nor very interesting, and Noeska’s 3DS loder is very mature and easy to use) decided to go for another format.

My first idea was to create a custom format, cause that would making coding a loader very easy and I would then just write a custom exporter. But after thinking a bit more about this, I dropped the idea. Why? Because for applications like the NewtonPlayGround (where I also want to use a new file format), where the user can use his own 3D models, it would’ve meant that I had to give out the exporter. That’s no problem for me, but since different people use different 3D modellers, they’d only be able to create own models when they own the 3D package I wrote the exporter for. So that was the “big no” that stopped me from creating an own 3D file format.

The second idea (and the one I finally went for) was to use an already existing 3D file format that is modern and has all the stuff that one would need for modern 3D applications. So I looked at different file formats, and the one that suited me most was the DirectX file format (.X) in it’s ASCII form (I may add loading of the binary version later on). It’s architecture- and context-free, so that it doesn’t matter what API you use it with. The only drawback : there is no (at least I didn’t found one) loader for that format so that one can use it with OpenGL (D3D has built-in functions for loading .X files). But after looking at how the ASCII-version of an .X file looks I sat down and started to write my own loader for ASCII .X files. And after some hours it can now load at least the basic stuff (meshes with all their properties, materials, etc.) and I finally (as seen in the screenshot) have the same normals in my apps as the ones I can “see” in my 3D modeller.