TriMesh2 Fork – A library for 3D mesh editing and I/O

During my first years in graphics development, I relied heavily on Szymon Rusinkiewicz’s C++ TriMesh2 library. It’s a nice set of tools for 3D mesh input/output, basic visualization and processing. I’ve come to use it in most of my projects. It imports .obj, .3ds and .ply files (amongst others), and puts all the triangle data in a structure that’s easy to query and manipulate.

I like it because of its great range of functionality, whilst keeping a low footprint, combined with a pretty straightforward implementation. Easy to adapt / fit to specific needs, though the basic usage (static compilation into your executable) will be fine for most use cases. It’s not the fastest or most compact library out there, but I feel it’s a very good starting point for mesh processing when you’re diving into graphics.

Since it is quite an old library, and Szymon is too busy with a lot of awesome research, I’ve taken it upon myself to fork the library, put it on Github (it’s the cool thing to do now!) and start fixing things.

The project name is simply TriMesh2 fork, for lack of a better title, and to keep the reference to Szymon’s work very clear. A lot of work was done pulling the project kicking and screaming into the modern MSVC compiler toolset, and I’m happy (most of) the tools compile under VS 2015 now.

A couple of improvements over the latest official (2.12) version:

  • Full MSVC 2013 and 2015 compilation support
  • 64-bit compilation support
  • MSVC support for building all the tools (mesh_view, mesh_cat, mesh_filter)
  • Win32/64 OpenMP compilation support
  • Gluit / Freeglut fixes
  • Lots of bug fixes / optimizations
  • CPPCheck validation

Check it out at

If you’re just interested in loading .obj files into your project, TriMesh2 – though great! – might be overkill – I would suggest using Syoyo Fujita’s excellent and impressive tinyobjloader for that.

In addition to the library itself, the following utility programs are included with TriMesh2

  • mesh_view: a simple 3D mesh viewer
  • mesh_make: create arbitrarily-tessellated meshes of various simple shapes
  • mesh_filter: applies a variety of simple transformations to a mesh, such as converting formats, flipping faces, subdivision, smoothing, rigid-body transformations, etc.
  • mesh_cc: list and/or extract connected components from a mesh
  • mesh_cat: combine several meshes into a single file
  • mesh_align: align 2 meshes using ICP
  • mesh_shade: a few procedural shaders for adding per-vertex color
  • mesh_check: check for some kinds of topological oddities (e.g., more than 2 faces at an edge) in a mesh file.
  • mesh_crunch: quick-n-dirty mesh decimation using the Rossignac-Borrel method of vertex collapse
  • mesh_info: print out some information about a mesh
  • xf: create or compose transformations in .xf files

Note: The supplied mesh_view tool does what it says on the tin, but is still using “old” OpenGL functionality. It’s glBegin() and glVertex3f() all the way. Since Opengl 3.x, Khronos moved from a fixed-function pipeline to a programmable pipeline (read: shaders all the way), which is now the most efficient, and only non-deprecated way to use OpenGL. For more info, check the excellent LearnOpenGL tutorials!