Supported OBJ File Syntax

The obj file format supports both polygonal and free-form surface objects. The Obj Reader/Writer currently supports polygonal face (f) objects (l) line and (p) point. Free-form surfaces are typically not used in .obj file exchange and are not supported at this time.

For completeness, the syntax supported is summarized below.

Syntax

Description

v <x> <y> <z>

Vertex position. Coordinates are floating point numbers.

vn <i> <j> <k>

Vertex normal. Coordinates are floating point numbers.

vt <u> <v> <w>

Texture coordinate

  • <u> is the horizontal direction
  • <v> is the vertical direction (optional in the case of a 1D raster/texture, and defaults to 0)
  • <w> is the depth in the case of a 3D raster/texture map (optional in the case of a 2D raster/texture, and defaults to 0)

f <v1>/<vt1>/<vn1> <v2>/<vt2>/<vn2> <v3>/<vt3>/<vn3> ...

Faces are stored as a series of three or more vertices in clockwise order. Vertices are described by their position, optional texture coordinate, and optional normal, encoded as an integer index into the respective coordinate lists. A face is generally limited to triangle or quad planar surface.

l <v1>/<vt1> <v2>/<vt2> <v3>/<vt3> ...

Lines are stored as a series of one ore more vertices and optional texture coordinate. Textures are generally not mapped to lines but may be used to store tabular data or an index.

p <v1> <v2> <v3> ...

Points are stored as a series of one or more vertices.

mtllib <filename.mtl>

Material (.mtl) file references the material file that defines the materials used in the object that follow. Material files contain color illumination components and texture filename references.

usemtl <mtlname>

Material name string tag that references the material to use for the faces that follow in the obj file.

g <groupname1> <groupname2> ...

Group name string tag for the elements (faces) that follow.

o <objectname>

Object name string tag for the elements (faces) that follow.

s <smoothgroup>

Smoothgroup number to group elements together for smooth shading operations.