TRI file format

Written by Paul Bourke
December 2001


This TRIangle file format just supports facet type models made up of triangular polygons (3 vertices). As such it is similar to formats such as VEF, the OFF format from the Geometry center, and the RAW triangle format.

Header

A TRI file consists of three sections, a one line header, the vertices, and finally the triangles. The one line header simply contains the number of items in the two subsequent sections, namely the number of vertices and the number of triangles.

Vertex section

Each line in the vertex section consists of one vertex made up of 9 numbers, they are the coordinate (x,y,z), the unit normal at that coordinate (x,y,z), and the colour at that coordinate (r,g,b). Each colour component ranges from 0 to 1.

Triangle section

Each line in the triangle section consists of three vertices given as integer indices into the vertex section. The indices start at 0.

Example

The following TRI file has 2048 vertices and 4092 triangles. The first triangle is made up of the first three vertices, namely vertex 0, 1, and 2.

2048 4092
0.081028 0.00519925 0.352117 0.099192 -0.058664 0.993338 0.6 0.5 0.4
0.150497 0.00501925 0.347408 0.011305 -0.114227 0.99339 0.6 0.5 0.4
0.115215 0.0552622 0.35306 -0.006704 -0.054489 0.998492 0.6 0.5 0.4
0.0118943 0.0562323 0.360595 0.127291 0.045234 0.990833 0.6 0.5 0.4
0.0114065 0.107345 0.357191 0.111191 0.066743 0.991555 0.6 0.5 0.4
  :
  :
  :
0.847981 -0.192869 0.0724376 0.438841 -0.805738 0.397749 0.6 0.5 0.4
-0.731624 -0.00203848 -0.367665 -0.55092 -0.492053 -0.674071 0.6 0.5 0.4
0 1 2
3 4 5
6 5 7
8 7 9
  :
  :
  :
407 1281 1911
1911 1281 410