CSG Subtract

Started by
5 comments, last by xgamerx81 22 years, 9 months ago
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.
Advertisement
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
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
Thanks, but I think those tutorials use a BSP tree, which I dont have right now.
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.
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
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
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!
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
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )

This topic is closed to new replies.

Advertisement