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 Graph

  • 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$ Jul 28 '17 at 15:28
  • $\begingroup$ There is a similar question in stackoverflow which could help you: stackoverflow.com/questions/14108553/… $\endgroup$
    – AlexM
    Jul 31 '17 at 7:04

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.