Jump to content
  • Advertisement
Sign in to follow this  
Etnu

[Cross post because this didn't seem to get any response in the math forum] - CSG

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

Ok, I'm a bit dumbfounded here. I've got 2 brushes, "A" and "B", each containing a series of convex polygons. If I want to subtract brush "A" from brush "B", what's the best way to calculate the new triangles to be rendered? I was looking through the unreal editor to see how the intersections worked. It seems as if they're never actually modifying the brushes, but rather just storing the information for the brush, and then calculating the triangles to be rendered each time you do a new subtract / add. I was thinking something like this:

struct Polygon
{
    Vert* Verts;
    int   NumVerts;
};

struct Brush
{
  Polygon* Polys;
  int      NumPolys;
};
void SubtractBrush(Brush* pBrush, Brush* pBrush2,Vert* pVerts);
{
    int iFilled = 0;
    for(int i = 0; i < pBrush->NumPolys; i++)
    {
        Polygon* poly = &pBrush.Polys;
        for(int iVerts = 0; i Verts < poly->NumVerts; iVerts++)
            if(!PointIsInBrush(poly->Verts[iVerts],pBrush2)
                Verts[iFilled++] = poly->Verts[iVerts];
    }
}
That would effectively create the 'new' brush, though of course I'm not 100% sure how to calculate the right order to render these vertices in to. Well, not exactly. I suppose i'd need to also create vertices at the point of intersection along the edges when they crossed into the subtractive brush, too. That further complicates things, but i'd be happy just knowing I had the correct vertices, much less having the correct triangles.

Share this post


Link to post
Share on other sites
Advertisement
Read this and see if it answers any of your questions.

http://www.3dtechdev.com/tutorials/illegalgeometry/illegalgeometrytut.html


-=[ Megahertz ]=-

Share this post


Link to post
Share on other sites
right, that was my second addendum...polys that intersect one another, as new vertices would need to be created.

I'm reading through this paper, though, it seems to be about what I'm looking for. Thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!