#### Archived

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

# How can I split polygons (quads) ?

This topic is 5994 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, Someone has a algo for spliting a quads with 4 vertex. Thanks in advance ... ======================== Leyder Dylan http://ibelgique.ifrance.com/Slug-Production/

##### Share on other sites
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 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

1. 1
Rutin
24
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 14
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631757
• Total Posts
3002142
×