What are the specifications for a Wavefront .obj file?

James picture James · Jul 16, 2012 · Viewed 14.4k times · Source

I want to write a parser for Blender's .obj file. The file format seems self explanatory, but also it seems to be missing some data. For example, a simple cube (the default Blender cube) has 8 lines of vertexes, but I was expecting to see 36 lines (12 triangles to form a cube).

I think the confusion, at lease for me, stems from the way cubes are created in direct3d. Direct3d requires 36 vertexes to form a cube. So I am thinking that I need to infer the other 28 vertexes. This type of guessing could cause issues later on when trying to parse vertexes for more complex shapes. So, I thought if I could find the official specs on the file format it might provide me with some insight into how to interpret the data.

It seems that someone else had asked the same question before: How to get proper number of vertices in OBJ file from DCC tools such as Blender for use in OpenGL ES? but it didn't have any useful information for me.

Answer

Tim picture Tim · Jul 16, 2012

OBJ Spec

MTL Spec (you'll probably want this too at some point)

FYI OBJ is in no way related to Blender, it's just a common file format for simple models.