Jump to content
  • Advertisement

Archived

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

Leyder Dylan

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!