- #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_triangle 0 i1 i2 i3
- This directive defines a triangle with vertices indexed by i1, i2, and i3 (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_triangle 0 0 1 3
#shape_triangle 0 0 3 2
#shape_triangle 0 2 3 5
#shape_triangle 0 2 5 4
#shape_triangle 0 4 5 7
#shape_triangle 0 4 7 6
#shape_triangle 0 6 7 1
#shape_triangle 0 6 1 0
#shape_triangle 0 1 7 5
#shape_triangle 0 1 5 3
#shape_triangle 0 6 0 2
#shape_triangle 0 6 2 4
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
- v x y z
- This directive defines a vertex at position (x,y,z).
- f i1 i2 i3
- This directive defines a triangle with vertices indexed by i1, i2, and i3, 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 1, which is different than the other file formats).
Here is a simple example for a cube in .obj format:
v -0.5 -0.5 0.5
v 0.5 -0.5 0.5
v -0.5 0.5 0.5
v 0.5 0.5 0.5
v -0.5 0.5 -0.5
v 0.5 0.5 -0.5
v -0.5 -0.5 -0.5
v 0.5 -0.5 -0.5
f 1 2 4
f 1 4 3
f 3 4 6
f 3 6 5
f 5 6 8
f 5 8 7
f 7 8 2
f 7 2 1
f 2 8 6
f 2 6 4
f 7 1 3
f 7 3 5