OpenGL ES : Dynamic calculation of triangle indices
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.
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.
Possibly Related Threads...
Thread:  Author  Replies:  Views:  Last Post  
glDrawElements and Face indices  Ashford  8  15,018 
Nov 11, 2009 03:03 PM Last Post: Ashford 

2D Dynamic Lighting in OpenGL! Sort of...  metacollin  22  20,162 
Aug 19, 2009 01:48 AM Last Post: Madrayken 

Trying to make a square... there's a triangle!  TimMcD  4  4,240 
Jun 2, 2009 03:41 PM Last Post: AnotherJake 

terrain texture coordinate calculation  akb825  12  9,241 
Feb 27, 2007 04:56 PM Last Post: akb825 

Triangle strip length  imikedaman  6  6,205 
Aug 6, 2006 05:32 PM Last Post: NicholasFrancis 