iDevGames Forums
OpenGL ES : Dynamic calculation of triangle indices - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: OpenGL ES : Dynamic calculation of triangle indices (/thread-9331.html)



OpenGL ES : Dynamic calculation of triangle indices - akademiks - Sep 13, 2011 07:58 AM

Hi,

I have a simple cube generated by code, where the indices and vertices are hardcoded.
I coded a function to slice it...adjusting the vertices to fit the slice plane using VBO
I now have an issue that i did not think of when coding my function...i can change the number of faces depending on the way i slice the cube

Ex: I slice one of the cube's corner at 45 degrees, i now have a cube with 7 faces and 10 vertices instead of 6 faces and 8 vertices...

In that case, its easy for me to update/add the new vertices created by the new face but the hardcoded indices (GL_TRIANGLES)
does not match the cube's vertices anymore. I need an algorithm to dynamically adjust the GL_ELEMENT_ARRAY_BUFFER depending on the updated vertices.

Is there any know algorithm to compute the triangle indices for a given polygon with known vertices?

Could someone point me in the right direction?
Thx.