PDA

View Full Version : converting rectangle into triangle strips?

GLpeon
01-28-2008, 12:37 PM
I am trying to convert a long thin rectangle into a series of triangles and then render this using triangle_strips.

I saw some code that does it like stripe, but that is way over my head, and I wish to learn how to do this. It doesn't have to be the best way for right now, just trying to learn how to do this, so that it is easy to understand.

What would be the best way to handle this?

Dark Photon
01-29-2008, 06:11 AM
I am trying to convert a long thin rectangle into a series of triangles and then render this using triangle_strips. ... What would be the best way to handle this?
How you bust your models into triangles isn't really an OpenGL question, but we'll help you anyway. :) Is this thin rectangle flat? If so, use two triangles and you're done. If not (it curls), then you need a criteria for determining how far apart you want to split the rectangle into smaller rectangles, which you can then render as quads or split in two and render with triangles. You probably want more sub-rectangles in areas that have higher curvature.

dorbie
01-29-2008, 02:58 PM
v1 v3
+---------------------------+
| |
| |
+---------------------------+
v2 v4

glBegin(GL_TRIANGLE_STRIP);
glVertex3fv(v1);
glVertex3fv(v2);
glVertex3fv(v3);
glVertex3fv(v4);
glEnd();

The order of the vertices is important. This will produce counterclockwise tris and won't bow-tie.