Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a 3D game lots of different systems need to know about geometry data, however the only way they seem to be able to agree to on in representing it by an array of triangles.

Can anyone recommend a good geometry manipulation library that will allow me to easily integrate the drawing library(OpenGL), the physics engine(Bullet), Serialization(Several 3D file formats) and my own code(objective-c++). Focus on the a representation between the drawing library and the physics engine. Also if the library can triangulate a mesh definition that would be very helpful. My code can work around what exists already.

share|improve this question
up vote 5 down vote accepted

There isn't really a standard format -- and there really shouldn't be, because you're asking about several widely different domains and applications of geometry data and efficient representations will differ for each.

That said, there are formats designed to facilitate content interchange. The most popular are Collada and FBX. This doesn't completely address your concerns though -- both formats are quite verbose and not actually well-suited to being used directly in memory, as a result. You'd probably want to condition them into some custom format your game can load most efficiently (the "array of triangles" you mentioned).

You generally want physics and render data to be different -- perhaps sourced from the same place, but there's no reason your physics meshes need to have colors and texture coordinates, for example. It's wasteful.

share|improve this answer
+1, and your collision meshes don't need as much triangles as your visible meshes, try to keep them as simple as possible. – Roy T. Mar 27 '12 at 18:26
That's true, but say I get a mesh defined as an Array of N-Gons, how should I get it into and array of tris? Is there a library that is good at manipulating such geometry information? – awiebe Mar 27 '12 at 19:08
@awiebe if they are convex N-Gons it's trivial to triangulate - just pick any vertex and make a fan from there. Otherwise you should pick an appropriate algorithm and find a library that implements it. – Adam Mar 28 '12 at 2:05
@awiebe - Also, most content creation packages (like for instance Maya) can triangulate meshes before they are exported. I'd strongly suggest you identify a set of assumptions that help you keep your code simple and try enforcing those assumptions as constraints with artists if you have the chance. Trying to have your code be able to make sense of any kind of geometry you throw at it is a conundrum I'd call a fool's errand. – Koarl Mar 28 '12 at 6:52

For a library I suggest you have a look at Assimp. It's a library for working with various mesh formats so you can just dump it in and get a full mesh importer with little in the way of work. It also allows you to load in a standardized format and output a custom one.

The problem is what format you store your meshes in will vary depending on your program and what features you need, what formats you are using internally. You are normally going to need some post-processing for things like converting filenames of images referenced by meshes. How are you going to link custom shaders and so on.

There are some standardized formats that you can use but they will tend to be over engineered for most realtime rendering and are more for use in the content creation pipeline. COLLADA is the main example (as the other post mentioned), it's found use from Sony with the PS3. Bullet Physics (and the Physics Abstraction Layer) apparently includes support for Collada. On the down side COLLADA is XML, so it requires parsing and needs to support a huge list of features making even a basic implementation quite a bit of work (for example it supports multiple coordinate systems, so if you want to support custom content you will have to take that into account, plain image textures have multiple levels of linages since the same format needs to support more advanced things like multiple textures and so on). With that said, in the past games often add support for importing the native formats of a 3d modelling program such as 3ds which wouldn't be too different so the overhead isn't that great. Although might be to much for mobile phones and some game console systems.

idGames such as the Doom 3 mesh format (MD5) is simply a plain text ASCII file. There are multiple files, one for geometry and another for animation. You could also have a separate one for physics as that will generally use lower polygon geometry.

Personally I would recommend using a binary format as your final mesh format. You can make a format that can be loaded into memory as basically a single block of memory and just requires some updating of pointers. The only potential problem is big endian vs little endian but just standardize on one and convert on the other.

Rather than using triangles it might be better to use an indexed vertex array of triangle strips for storage as it should save a bit of storage space (and ram when loaded into memory) but it does require some conversion to the format.

share|improve this answer

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.