Archived

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

xgamerx81

CSG Subtract

Recommended Posts

Hi, I''m working on a map editor that uses brushes. I have gotten to the point where I want to add CSG Subtract. In other words, let''s say I have Brush A and Brush B. I want to carve up B using A. I''m sure this involves using plane and polygon splitting, but I have no idea how to do it. Can anyone help me? Thanks for any help.

Share this post


Link to post
Share on other sites
Search for a Guy called Dan Droyer.. he has some good articals ''bout it.. I''m interessted in that too, but in my Leveleditor there are some things that go before that (entity system.)

cya,
Phil


Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states

Share this post


Link to post
Share on other sites
Maybe someone could show me some pseudo code? My guess is that you loop through the faces of the brush being subtracted, and use them to cut the brush being subtracted from, but I still don''t have any idea.

Thanks again for any help.

Share this post


Link to post
Share on other sites
You don''t wanna code CSG without BSP... that''s my guess... I heard from some people that it''s faster to just build the BSP tree, Subtract them from each other and then delete the tree... Doing it without such a structure ends up with a lot of if statements that you''ll double check... and I don''t want to debug it :o)
cya,
Phil


Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states

Share this post


Link to post
Share on other sites
Ok, I figured out how to do it, and already have it working in my editor.

Let''s say you have brush A and brush B. You want to subtract B from A, so FINAL = A - B. For every plane in B, you split brush A. The new split is added to FINAL. After splitting, the polygons left in A are the intersection of A and B, which you delete. FINAL is a list of brushes that were cut off brush A, and are the finished product.

I hope this helps anyone who wants to learn CSG subtract!

Share this post


Link to post
Share on other sites
Ok.. nice.. but you''ll have awful lot a splits and it''s slower.. also it doesn''t work on convex hulls.. thx for the tipp anyhow :O)

cya,
Phil


Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states

Share this post


Link to post
Share on other sites