The .obj format is the default format for Alias/Wavefront products. It is also one of the most common 3D object formats around.

The basic format is very simple, although it does have a lot of more complex features like bezier curves and splines. To do basic vertex modelling, the commands needed are as follows:

  • # something
    This makes the rest of this line a comment.
  • v x y z
    This specifies a vertex with coordinates x, y, z. The first v will be indexed 1, the second 2 and so forth.
  • vn i j k
    This specifies a vertex normal with components i, j, k. The first vn will be indexed 1, the second 2 and so forth.
  • vt x y
    This specifies a texture coordinate with x, y. The first vt will be indexed 1, the second 2 and so forth.
  • f v v v...
    This creates a face with vertices v. v is an integer representing the index of the vertex required.
  • f v/vt v/vt v/vt...
    This creates a face with vertices v and texture coordinates vt. v and vt are integers representing the index of the vertex and texture coordinates required.
  • f v/vt/vn v/vt/vn v/vt/vn...
    This creates a face with vertices v, texture coordinates vt and vertex normals vn. v, vt and vn are integers representing the index of the vertex, texture coordinates and vertex normal required.

Using this system, the .obj code for a cube could be:

# Exported from Wings 3D 0.98.02
v -1.00000 -1.00000 1.00000
v -1.00000 1.00000 1.00000
v 1.00000 1.00000 1.00000
v 1.00000 -1.00000 1.00000
v -1.00000 -1.00000 -1.00000
v -1.00000 1.00000 -1.00000
v 1.00000 1.00000 -1.00000
v 1.00000 -1.00000 -1.00000

vt 0.00000e+0 0.499999
vt 0.00000e+0 0.500001
vt 0.00000e+0 1.000000
vt 1.83660e-6 0.00000e+0
vt 0.499999 0.500001
vt 0.499999 0.500001
vt 0.499999 1.000000
vt 0.500001 1.83660e-6

vn -0.577350 -0.577350 0.577350
vn -0.577350 0.577350 0.577350
vn 0.577350 0.577350 0.577350
vn 0.577350 -0.577350 0.577350
vn -0.577350 -0.577350 -0.577350
vn -0.577350 0.577350 -0.577350
vn 0.577350 0.577350 -0.577350
vn 0.577350 -0.577350 -0.577350

f 1/4/1 4/1/4 3/1/3 2/4/2
f 1/4/1 5/8/5 8/5/8 4/1/4
f 2/4/2 6/8/6 5/8/5 1/4/1
f 3/6/3 7/7/7 6/3/6 2/2/2
f 4/1/4 8/5/8 7/5/7 3/1/3