• Advertisement

Archived

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

Polygon splitting and vertex ordering

This topic is 5501 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

Hey! I know this would perhaps fit better in "graphics programming and theory", but i would like as much people to see this as possible So anyways, my problem is quite uncommon i believe, because i haven't found a single article about HOW to split polygons. Thats why i ended up making my own algo for it... The function prototype goes like this: bool CPolygon::Split(CPlane& Plane, CPolygon*& pFrontPoly, CPolygon*& pBackPoly) So as you can see, the polygons are split, by a plane crossing them, into two polygons (one on each side of the plane), the polygons are returned using pointer references (so i can actually modify what the pointers provided to the function are pointing to). One very important particularity is that these polygons arent necessarily triangles, they are n-gons (3 or more sides, mostly quads). I have evaluated that since the polygons are convex, only two edges can cross the plane, resulting in the fact that the front polygon, for example, has the same amout of vertexes as the number of vertexes of the main polygon (being splitted) that are on the front side plus two, because the front and the back poly both have two common vertexes that are touching the splitting plane. So my big problem is that, in my algo, i need to reorder the front and back polys so they have the same normal as the main polys, keep in mind that this isnt as easy as it seems since they can have any number of sides. I dont know how to do this (i tried a couple methods, searched the web, cant find). My algo goes like this: - Store the vertexes that are on each side of the plane in two stl-like vectors. - If either of those vectors are empty, return false, because that means the poly has all its vertexes on the same side of the plane and therefore cannot be splitted. - Find out which edges of the polygon being splitted are crossing the plane, calculate the position of the two vertexes that will touch the plane and the texcoords from that - Reorder the front and back vertexes + texcoords so that each polygon has the same normal as the polygon being splitted - Create two new polygon objects and store their memory address in the two pointers passed to this function - Copy the vertexes and texcoords from the stl like vectors to the front and back polygons we just created - Store generic properties in the two polygons (color, material, texture) - Success, return true This is not an easy problem But i need it done, because i can't really build a proper octree if i dont split the polygons, it just gets too nasty on many aspects. Apart from this ordering problem, things seem to be going good, some polys are actually properly ordered (random order) and the texcoords are fine.

Looking for a serious game project?
www.xgameproject.com [edited by - Max_Payne on January 31, 2003 11:51:14 AM]

Share this post


Link to post
Share on other sites
Advertisement
Check out this paper written by Stefan Hajnoczi. It has a section daling with sorting vrticies, as well as splitting poly''s. PLus much more.

Here''s the paper: MAPFiles.pdf

-Zims

Share this post


Link to post
Share on other sites

  • Advertisement