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.

  • \$\begingroup\$ You should consider adding a pygame tag. It would make your question less ambiguous since each platform handles importing models differently. \$\endgroup\$
    – Soviut
    Commented Dec 23, 2010 at 4:38
  • \$\begingroup\$ Removed the "best-practices" tag and added "pygame". \$\endgroup\$
    – r2d2rigo
    Commented Dec 23, 2010 at 10:36

3 Answers 3


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.

  • \$\begingroup\$ 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! \$\endgroup\$
    – malvim
    Commented Dec 27, 2010 at 13:01
  • \$\begingroup\$ 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. \$\endgroup\$
    – S.gfx
    Commented Dec 31, 2010 at 9:10
  • \$\begingroup\$ Good answer. Never heard of collada, and that was a big help. \$\endgroup\$
    – bentford
    Commented Mar 27, 2011 at 19:14

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


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.

  • \$\begingroup\$ 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. \$\endgroup\$
    – malvim
    Commented Dec 20, 2010 at 4:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .