Home

Awesome

libtri

Library for working with the .tri file format. The .tri file format consists of a text-based header (extension .tri) containing the relevant model info and a binary data file (extension .tridata) containing the actual model data..

In order to use this library, you also need to have the header-only glm available in your build path.

You can read the header info into a TriData struct using the methods in tri_tools.h. To read the actual data from the .tridata file, you can use the TriReader.h class.

Tri File Format

The .tri file format is a very simple internal format to make abstraction of all the pitfalls and peculiarities of the plethora of model input formats in the wild. It basicly lists all triangles as one long list, with optional triangle properties (normals, colors ...) right behind the triangle definition. It was created with regards to streamability: all triangle information is stored sequentially, so you don't need to load the whole file in memory to process triangles. It's not as space-efficient as other formats, but is trivial to understand and parse.

###Tri Header A typical .tri header file is text-based and looks like this. All keyword - values lines are separated by a newline:

#tri 1
ntriangles 8254150
geo_only 1
bbox  -2540.83 -2586 -15957 2699.43 2654.25 -10716.8
END

All elements are required.

Tri data file

A .tridata file is a very simple binary file which just contains a list of the x, y and z coordinates of the triangle vertices (v0, v1 and v2), followed by the optional payload per triangle (normal, texture information, ...).

In case of geometry-only (or, confusingly called binary, as in binary voxelization) .tridata files, the layout per triangle looks like this:

In case of a payload .tridata file, the layout per triangle is followed by