Wavefront OBJ Format

Wavefront's Advanced Visualizer's object file describe geometries along with their attached properties. These files can be formatted in either ASCII(.obj) or binary(.mod).
This documentation and this software are only concerned about the ASCII format and mesh objects, binary and other geometries will be ignored.

File description

The structure of the ASCII format is the following:

  • Each line start with a directive followed by a series of attributes. These can be anything from including an external file to parse to making a call to a UNIX function to describing a NURBS. This software only parses 3 types of line:
    1. g followed by a name. This defines a group of elements. For this software, if the following elements are faces, this is a new mesh.
    2. v x y z with x, y and z corresponding to the vertex'coordinates. There may be an extra parameter w but since it is for rational curves and surfaces, this is ignored.
    3. f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3... with each triplet v/vt/vn describing the coordinates, texture and normal of the face's vertex. vt and vn are ignored.
  • The following is an example of 8 triangles forming a square, do note that faces do not necessarily need to be triangular:
    v -1.38639 1 1
    v -1.38639 1 1.11022e-016
    v -1.38639 2 1
    v -1.38639 2 1.66533e-016
    v -1.38639 -8.4892e-017 5.55112e-017
    v -1.38639 -1.46124e-016 1
    v -1.38639 -2.07357e-016 2
    v -1.38639 1 2
    v -1.38639 2 2
    
    g grid_0
    f 1 4 3 
    f 1 2 4 
    f 6 2 1 
    f 6 5 2 
    f 7 6 1 
    f 7 1 8 
    f 8 1 3 
    f 8 3 9