Sign in to follow this  
GogetaX

OpenGL 3D Object file format..

Recommended Posts

Hey all, im heaving a hard to time to pick the right object format for OpenGL.. X, 3DS, Obj, Milkshape etc. there are soo many.. but i wanna know wich one is the best and got the most support? i aslo would like an a tutorial of a sample of how to load it.. thanks..

Share this post


Link to post
Share on other sites
hey.. unfortunately there is no native opengl support for any model format.. so any format you pick will require you to either use a third party library or you need to right your own loader.
Obj is pretty simple and there are a few loaders online, but it only supports basic features. X is not a great format imo, even MS seem to have abandoned it. I also was looking for a good format so that i could use models created in Maya, but I couldn't find anything that pleased me, and eventually ended up making my own format/importer/exporter..
So out of my lack of success, I wish you luck and hope you find things I didn't.

Share this post


Link to post
Share on other sites
yosh! thanks for the info dude..
i guess i gonna use the milkshape file formats cuz i seen it supported most by some tutorials i found online.. ill just have to get an exported to 3dmax for that format..
good luck to me xD

Share this post


Link to post
Share on other sites
What about collada? I went through the spec and it seems to cover just about everything. I plan to use it myself. There are also plugins to import/export to/from Maya and 3D Studio.

http://www.khronos.org/collada/

Share this post


Link to post
Share on other sites
Hello,
of those who's you mentioned, the strongest is MilkShape file format, I personally use it too.
Why? - It supports skinning mesh animations (with vertex weight), mesh groups, material parameters and so on...
Also Milkshape supports many other file formats, which allows you to model and animate your objects in other software (like 3dsmax or Maya).

Share this post


Link to post
Share on other sites
I also agree, obj is ridicolous simple to write own loader for. For static geometry and simple demos it is just fine. It is also trivial to extend it to support own objects such as cameras for example, there is also built-in support for user objects (with 'o' command), but it isn't difficult to add custom commands too, which seems to be quite common thing to do.

It is done to be written by hand, that is reason why it is so easy to work with it. But for same reason, it is not so usefull in production code since there are no forward specs for number of vertices, faces and so on - also there is overhead in parsing it. Adding more advanced features like skinned meshes is probably quite messy, so .obj format is not used so much for animated objects.

Another great and quite used format is lightwave's .lwo format, which is binary chunk-based format, written for fast loading which also has support for many more features than .obj, inclusive skinned meshes and such. It is alwo well docimented and there are lots of code online you can sue.

I found .X to be really great format. It supports skinned meseshes, curves and kitchen sinks. It commes in both binary and text flavour. It is also created with (user) extensibility in mind, so there is well-thaught and documented support for adding custom funcionality.

One of reasons to its un-popularity in past was its implementation. Microsoft shipped a library to read/write .X files only with DirectX, which is ugly written win32 dependent library. So nobody but directx developers really used this format. However it is open format and it is totally possible to write loader/writer for any API, OpenGL included. I think there was some attempt too, google around, there might be some open source library for .X files too.

Another reason to its impopularity is political, due to microsofts popularity of time, .X like everything else microsofts, enjoyed same bottom level popularity in some people minds.

Reason why microsoft seems to abandon the .X is probably due to it's structure - it is not XML. These days everything should be XML, especially if it is going to work with DNA. I am not sure about this, but I guess this is the reason. This is quite bad decision, but MS tried to kill COM and other stuff in flavour of .NET so I am not surprised it they wish to kill .X in favour of something XML.

You can read more about .X: http://local.wasp.uwa.edu.au/~pbourke/dataformats/directx/ or just use google, there are tons of references about it.

If you are starting out I suggest .obj to start with and move on to something better once you start playing with skinned meshes and animation.

If you prefer XML, Collada, W3D or VRML might be something to look at.

Share this post


Link to post
Share on other sites
Assimp loads them all.

For simple static meshes, .obj is actually fine. For more complex scenes, Direct3D .x files or Collada .dae files are better. Both support skinning and animation, which you usually need in a game. .3ds is fine for static models, as well - it's not read easily, but there's a lot of programs out there which can output .3ds files.

Share this post


Link to post
Share on other sites
I would personally either choose the ms3d, .obj, or .blend formats. Making an obj reader is INCREDIBLY simple, since it's a text based file format. the ms3d format is fairly common, and is created from a great 3d editor. Also, nehe.gamedev.net has some ms3d loading code (lesson 31). As others have said, it's a good format. Finally, i choose the .blend format because it's the native file format for the Blender editor, which is almost as good as milkshape (maybe as good), and it's FREE. So, blender is good if you're on a budget. And why waste so much money for an editor when you can get one almost as good for free (it's only a 30 day trial period that's free)?

So, happy coding! the format that I've used is the .obj format because it's simple to use and very widely known.

Share this post


Link to post
Share on other sites
opengl itself has nothing to do with the file format. you can use anyone or something of yourself.

i'd like to use obj files, for the reason that obj is a text file, so i can open the file to check what's inside for quick debugging.

the difficulty of using an obj file is that the file reader is more complicated than a binary file reader.

Share this post


Link to post
Share on other sites
I've just written a .obj loader, and I have to say that it's more complicated than it looks, thanks to the .obj's multi-indexed format (separate indexes for verticies, normals and texture co-ordinates).

Regards
elFarto

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this