I trying to highlight vertices which are on "borders", imagine half of sphere for example. Also for example I added image geomtry with triangles and highlighted necessary vertices. Any ideas? Thanks
-
2$\begingroup$ How are you currently storing your mesh data? For example do you have a half-edge data structure, or just vertex/index buffers, or something else? $\endgroup$– Nathan ReedCommented Jul 28, 2017 at 15:28
-
$\begingroup$ There is a similar question in stackoverflow which could help you: stackoverflow.com/questions/14108553/… $\endgroup$– AlexMCommented Jul 31, 2017 at 7:04
2 Answers
I'm assuming you are rendering this object as a set of triangles. To do what you are trying to do, you will need to store all your triangles (and vertices) in some sort of buffer or list. Then, for each triangle, test if all three of its sides are matched with another triangle side. If so, it is enclosed and inside the object. Otherwise, it is outside the object. Some basic pseudo-code (I apologize for all the foreach loops :) )
foreach t in triangles:
all_sides_touched = True
foreach side_t in t:
this_side_touched = False
foreach u in triangles.exclude(t): // run through all other triangles to test
foreach side_u in u:
if side_t.equals(side_u): this_side_touched = True
all_sides_touched = all_sides_touched and this_side_touched
if not all_sides_touched:
foreach side in t:
foreach point in side:
// do whatever you want to do with outside vertices
A close solution would be like How to detect border vertices of an open mesh 3d model? | Stack Overflow
For edge, you test in the edge is connected to at least 2 triangles. If it is not the case, the edge is a border under the assumption that the mesh is a manifold.