Search code examples
openmesh

Is there a way to reproject/interpolate vertex colors with OpenMesh?


I'm using OpenMesh to remesh/manage some mesh objects. With subdivide/decimate/smooth and other tools from OpenFlipper, I can change the mesh topology.

This however results in vertex colors loosing their meaning, as new vertices will all have black color and there is no interpolation when mesh topology changes, resulting in visual artifacts.

Is there a way to tell OpenMesh to reproject vertex colors back to the old mesh to interpolate the vertex color? If not, what would be a good way to do it manually? Is there any state of the art for vertex back-projection?


Solution

  • In OpenFlipper using requestTriangleBsp() you can request a BSP tree for your original mesh object. (You will have to keep a copy of your original mesh as long as you want to use that BSP tree.) Whenever you want to project a point onto your original mesh, you can then use the nearest() member function on the BSP tree in order to get the closest face to the supplied point. After that it's only a matter of projecting your point into that face, computing barycentric coordinates and interpolating the vertex colors.