What are the specifications for a Wavefront .obj file?
Asked Answered
D

1

24

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.

Dogmatize answered 15/7, 2012 at 23:48 Comment(2)
Here's a basic explanation. There are 8 vertices, however you then have face data (f lines) down the file that specify which vertices make a face.Bespeak
Just a note to say that blenders OBJ files are not different in any important way from other OBJ files (no special blender-only data), if you're writing a reader - you can just lookup docs to support the wavefront OBJ spec.Dido
E
29

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.

Evadne answered 15/7, 2012 at 23:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.