Archived

This topic is now archived and is closed to further replies.

Leyder Dylan

How can I split polygons (quads) ?

Recommended Posts

I'm assuming your trying to split it in two triangles.

The algo is very simple :

A---------B
|00000000|
|00000000|
|00000000|
D---------C

So the 2 tris are : ABC and ADC or ABD and BCD

Very simple , all you need is to store the vertices Counter clockwise or clock wise. In your mind you have to draw a line between B and D or A and C.

Don't mind the 0's in the quad, they keep te |'s appart.

Edited by - George2 on February 20, 2002 2:58:07 PM

Edited by - George2 on February 20, 2002 2:58:48 PM

Edited by - George2 on February 20, 2002 3:01:05 PM

Share this post


Link to post
Share on other sites
If you''re just trying to change a quad (or most any polygon) into 2 (or more for polygons) triangles, the best thing to do is use a triangle fan.
glBegin(GL_TRIANGLE_FAN);

The first vertex is your origin, then the others are points on the shape. It will draw a triangle with vertecies origin, vertex1, vertex2
then origin, vertex2, vertex3
then origin, vertex3, vertex4
and so on
So, if you want to break up a quad, all you have to do is change glBegin(GL_QUADS) into glBegin(GL_TRIANGLE_FAN), but please note: for every quad, you need to glEnd() before you draw another one.

Legends Development Team

Share this post


Link to post
Share on other sites