简体   繁体   中英

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.

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)

As the OP has mentioned MeshLab has a provision to color edges with custom user selected color (same color for all edges) or with vertex/face color (edge connecting to vertices with different color will have a gradient color). It can be done by enabling Wireframe rendering and selecting edge color from the options.

在此输入图像描述


However, MeshLab does not support rendering the edges with specific edge color attribute. I might be wrong but popular simple mesh formats like obj and off do not have a provision to store edge attributes (color, thickness etc.). I was under the impression ply also doesn't support this, but the link provided by OP says otherwise.

The only solution I can think of is to write your OpenGL renderer to draw lines instead of triangles. And while writing the mesh, write vertices for every edge with edge color assigned to them, ie if you have 3 edges connected to a vertex, that vertex will be repeated thrice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM