Search code examples
3dmeshmeshlab

Coloring mesh edges in meshlab


I have been working on an algorithm that takes a mesh, does some fancy things with it, and produces some output.

To visualize the result I decided to produce a copy of the mesh, colour it in a smart way that is somehow related to the produced output, and visualize it with Meshlab. However, I need to color some of the edges of the mesh differently from others.

After googling for several hours, I haven't been able to find a way to do this, even though the file formats (.obj, .ply ...) seem to support this behaviour, as suggested by this tutorial (which I followed to produce the output mesh).

I have produced a work around, which is, to each vertex I assign the colour of one of the edges it is adjacent to, and then I just colour the edges based on the vertex colour, but unfortunately, this means that (for example) edges that are of two different colours will be rendered with a gradient from one colour to the other, which is not the intended behaviour.

Am I doing something wrong here? (Like ignoring some patently obvious option). Or alternatively, is there an alternate way of rendering the mesh that would allow one to colour edges (that wouldn't imply coding one's own renderer or spending 3 days scouring through blender's manual looking for the right key combination)?

Any help would be very welcome. Thanks in advance.


Solution

  • I came up with a hack that mostly got me the job done.

    Here goes: Take the original mesh, and for every edge make a new point which is just the midpoint of this edge. Connect both the edge vertices to this midpoint to form a zero area degenerate triangle. Add this triangle, and this point to the mesh file. You guessed it, color this new vertex with the edge color.

    Once you fiddle with the background color settings of meshlab, you will be able to see the edge colored mesh reasonably well.

    (The one thing I am still trying to find out is how to increase the thickness of the lines so it appears more clear. Right now, you can just go to vertex view, and see the new points all light up nicely with the edge colors)