2
\$\begingroup\$

So I've not been able to find much online about how data should be stored for triangle adjacency.

Currently I calculate my adjacent using half-edges (mention in an answer here).

But do I store this data in with my VBO? (Which means twice the vertex data) Or do I store it in my element array buffer? And if so how do I tell opengl the interleaving I would have in it?

\$\endgroup\$
3
\$\begingroup\$

You can store it in your GL_ELEMENT_ARRAY_BUFFER since the vertex data is just repeated for the adjacency verts.

Assuming that each consecutive 3 indices defines a triangle, and that "unsigned *ndx" points to an arbitrary triangle in your buffer, then 6 consecutive indices will define a triangle with adjacency, as follows:

  • ndx[0] - index 0 of the original triangle
  • ndx[1] - index of the vertex that completes the adjacent triangle for {0,1}
  • ndx[2] - index 1 of the original triangle
  • ndx[3] - index of the vertex that completes the adjacent triangle for {1,2}
  • ndx[4] - index 2 of the original triangle
  • ndx[5] - index of the vertex that completes the adjacent triangle for {2,0}
\$\endgroup\$

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.