I would like to be able to retrieve all individual polygons from a PShape object (preferably an imported .obj) in order to know which vertices are linked to each other.
for example if I was to import a simple tetrahedron i would like to retrieve the indices of the vertices linked to a vertex with a given index.
since a tetrahedron has 4 vertices this should give me something like this:
vertex 0 is linked to the vertices 1, 2, 3
vertex 1 is linked to the vertices 0, 2, 3
vertex 2 is linked to the vertices 1, 0, 3
vertex 3 is linked to the vertices 0, 1, 2
This could theoretically be achieved by checking which vertices are contained in which polygon, but I have no idea what methods to use for that or if an appropriate method even exists. Anybody got any suggestions?
EDIT: So I figured out that
PShape.getChild(index)
returns a PShape that consists of the polygon at the index.
Calling
getVertex()
on that PShape returns the 3 vertices of that Polygon so that’s a step forward.
Stil, what I would like to do is to know which Vertex is attached to which Polygon globally in order to see which Vertices are neighbors. Hope somebody can help me out