- #vertex_num n
- This directive specifies the number of vertices in the file. It must appear before the first vertex.
- #vertex x y z nx ny nz ts tt
- This directive defines a vertex at position (x,y,z) with normal (nx,ny,nz) and texture coordinates (ts,tt). The normal and texture coordinates will usually be zero in the input files -- they can be created and output by your program.
- #shape_polygon 0 nverts i1 i2 ... in
- This directive defines a triangle with nverts vertices indexed by i1, i2, ... in (ignore the first field which will always be zero in this assignment), where the vertex identifiers correspond to the order of previously defined vertices in the file (note that the first vertex defined in the file has integer identifier 0).
Here is a simple example for a cube in .ray format:
#vertex_num 8
#vertex -0.5 -0.5 0.5 0 0 0 0 0
#vertex 0.5 -0.5 0.5 0 0 0 0 0
#vertex -0.5 0.5 0.5 0 0 0 0 0
#vertex 0.5 0.5 0.5 0 0 0 0 0
#vertex -0.5 0.5 -0.5 0 0 0 0 0
#vertex 0.5 0.5 -0.5 0 0 0 0 0
#vertex -0.5 -0.5 -0.5 0 0 0 0 0
#vertex 0.5 -0.5 -0.5 0 0 0 0 0
#shape_polygon 0 4 0 1 3 2
#shape_polygon 0 4 2 3 5 4
#shape_polygon 0 4 4 5 7 6
#shape_polygon 0 4 6 7 1 0
#shape_polygon 0 4 1 7 5 3
#shape_polygon 0 4 6 0 2 4
Object File Format (.off)
OFF files are simple ASCII files containing only vertices and
faces. The file begins with the keyword OFF. The next
line states the number of vertices, the number of faces, and the
number of edges. The number of edges can be safely ignored.
The vertices are listed with x, y, z coordinates, written
one per line. After the list of vertices, the faces are listed, with
one face per line. For each face, the number of vertices is specified,
followed by indices into the list of vertices (note that vertex indices
are numbered starting at 0). See the examples below.
OFF
numVertices numFaces numEdges
x y z
x y z
... numVertices like above
NVertices v1 v2 v3 ... vN
MVertices v1 v2 v3 ... vM
... numFaces like above
Here is a simple example for a cube in .off format:
OFF
8 6 0
-0.5 -0.5 0.5
0.5 -0.5 0.5
-0.5 0.5 0.5
0.5 0.5 0.5
-0.5 0.5 -0.5
0.5 0.5 -0.5
-0.5 -0.5 -0.5
0.5 -0.5 -0.5
4 0 1 3 2
4 2 3 5 4
4 4 5 7 6
4 6 7 1 0
4 1 7 5 3
4 6 0 2 4