How can I split polygons (quads) ?
Hi,
Someone has a algo for spliting a quads with 4 vertex.
Thanks in advance ...
========================
Leyder Dylan
http://ibelgique.ifrance.com/Slug-Production/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
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
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
"THE INFORMATION CONTAINED IN THIS REPORT IS CLASSIFIED; DO NOT GO TO FOX NEWS TO READ OR OBTAIN A COPY." , the pentagon
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
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
Legends Development Team
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement