Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm a total noob with regard to game programming (though not a noob to programming) and I'm using pygame + opengl to do some experiments with a little game I've been thinking of.

I've been trying to import OBJ files into my pygame OpenGL "game", but there's apparently different formats of OBJ files, and writing a loader is a fairly nontrivial process. At least from my experience, which is not too large.

So I guess my question is: What do people generally use in the industry to read 3d model files? What about animation? Is there a place I can look into to understand?

Thanks, Marcelo.

share|improve this question
You should consider adding a pygame tag. It would make your question less ambiguous since each platform handles importing models differently. –  Soviut Dec 23 '10 at 4:38
Removed the "best-practices" tag and added "pygame". –  r2d2rigo Dec 23 '10 at 10:36
That makes a lot of sense, thanks! –  malvim Dec 25 '10 at 5:37
add comment

3 Answers

up vote 2 down vote accepted

Reading your comment,Malvin, was better to post this as a new answer:

Malvin, OBJ is quite used for static models. But for character animations, you need to be able to transport bones information, and vertex weights (the value with which each vertex is influenced by several bones, or only one, or none). Also constraints info, in some cases. That all would be the "rigging" info, basically. Then there's animation info needed, like keyframes (frames where some change happens), interpolation type between them, etc, etc. All these is not supported by OBJ. A good, lightweight and practical format for this is *.md5 , but is probably more recommended Collada, which is becoming a very adopted standard and that can port everything, from statics, scenery, to character animation. It is supported by the big ones: Maya, Max, XSI. Blender is supporting it but not yet fully. The collada issue is that is complex to make yourself a loader, as is a very complete format, and for this reason, several packages don't have a fully functional exporter for this. Still, might be the way to go.

You can of course dump OBJ frames from an animation package, and then interpolate in the engine, as exporting one obj per frame would be too much heavy and costs memory. Maybe one every 2 or 4 frames...

You can also use FBX for character animations, but my advice would be using collada instead of it.

First of all, check if your artists are going to be able to export in whatever the format, from their package. Otherwise is a hard to solve problem. Indeed, make complete tests of features ported and and confirm is working in your engine.

About what people is doing, in my experience, all of this... But in game companies, often just they do a converter from whatever format to a custom, native, binary format for their engine. Optimized and faster to load, etc.

I have done prototypes or even games just using OBJ or ASE and md5 for animations..Depends on artists workflows, toolset, etc.

Edit: Sorry, seems Fuzzy had already answered several matters. Agreeing there.

share|improve this answer
Didn't know COLLADA supported animations, I'm a total newbie in gamedev. This seems like a good point to start, so I'm accepting this answer. Thanks to everyone for their input, though! –  malvim Dec 27 '10 at 13:01
If you were just making a 3d space invaders, or other game involving just static meshes, maybe going for collada, making a sort of more complex loader than the easy OBJ, could be an overkill. But even so...going for the most complete format would make it easier for you to load more complex stuff later on, using the same loader base. Yet though, as mentioned,in actual game companies often is a plugin that allows even using Max viewport as an engine preview,they build plugins, or converters+native format, so often no standard formats are used. For an indie, collada is a great route,though. –  S.gfx Dec 31 '10 at 9:10
Good answer. Never heard of collada, and that was a big help. –  bentford Mar 27 '11 at 19:14
add comment

You should use existing options that someone else has already fought.

1) http://assimp.sourceforge.net/ Open Asset Import Library supports a huge amount of formats.

2) http://openctm.sourceforge.net/ A very nice LZMA based mesh compression system with SDK's.

Also, "industry" usually use what they have in their toolset. Collada is common, FBX is common, Proprietary formats even more so. Some studios use .MAX directly, maya scenes directly. Alot of studios also go for transport formats (see opaque data, and such) where the animation software is extended via tools and plugins to feature the game ready tools, instead of working backwards from a mesh format.

For example, Naughty Dog use Maya exclusively as their main 3d content tool See this link : http://usa.autodesk.com/adsk/servlet/item?linkID=10225710&id=7670571&siteID=123112

share|improve this answer
add comment

Writing a loader for OBJ models shouldn't be too hard. Its one of the simpler model formats out there. You only have to use what you need and if you are making your own models you can tailor what is exported to only what you need.

I believe there is only one OBJ format, but each file can have parts omitted depending on what the model requires. One model might not use texture coordinates, so they would be missing in the file for example.

Basically your loader would look something like this:

for all lines in file
 Read next non empty line
  Get first token
   if token is #, skip line
   else if token is v, make a vertex
   else if token is vn, make a normal
   else if token is vt, make a texture vertex
   else if token is f, make a face

You would store a list of vertices, normals, texture vertices, and faces. Each face would store indices into the other lists.

Most simple models would not have more than that, even though the OBJ format can handle curves and other non polygonal data. I would bet you don't want to handle any thing else either.

http://www.royriggs.com/obj.html is a good page to look at specifically for OBJ files.

What model format is used in a project depends on the engine used. For example, if you use Unreal, they have a model converter that converts model files from a 3d modeler into the unreal format. If you use a custom engine, you would probably have written your own model format, or at least your own model reader.

share|improve this answer
First of all, thanks for your answer. As much as I understand that writing an OBJ loader is not too hard, my question was more of a "what are people using out there?" kind of thing. For example: What if I wanted to animate my character? Would I get several OBJ files from a 3D modeler, or do people load entire animations from whatever 3D software they use? Things like that. –  malvim Dec 20 '10 at 4:06
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.