Cutting a polygon out of a polygon
Hi!
Do you know UnrealEd? If you build two cubes in UnrealEd and move them so that both cubes are side by side, UnrealEd automatically connects these two rooms by cutting out the face of the smaller room from the face of the larger room. So the both cubes are no more closed but have a hole so that you can move from the one cube to the other cube.
I have no idea how this is done and I can''t find any information on 2D CSG operations. Can anyone give me some hints how to do such things?
Thanks in advance
LaBasX2
Well a cube is 3D so you would want to do 3D CSG. You are desribing the CSG union operation, I''m using it in my engine, and there are some good tutorials on it around the net, eg:
http://www.3dtechdev.com/tutorials/illegalgeometry/illegalgeometrytut.html
What it does is combine the brushes so that any polygons or parts of polygons that are inside other brushes are clipped away and you are only left with the polygons that form the total exterior of the brushes.
Let me know how you get on,
FatalXC
http://www.3dtechdev.com/tutorials/illegalgeometry/illegalgeometrytut.html
What it does is combine the brushes so that any polygons or parts of polygons that are inside other brushes are clipped away and you are only left with the polygons that form the total exterior of the brushes.
Let me know how you get on,
FatalXC
wow, that''s cool, but how do i do it in 2d? if i have a set of vertices defining the first polygon, and a set of vertices defining the second, how do i subtract them? thanks in advance,
shurcool.
shurcool.
tnx FatalXC for the good tutorial link.
however it still doesn't go into the actual detail of polygon/polygon clipping and does it more conveniently with convex objects. however thats al very handy but when doing a bit of combinatory boolean tech 2 things come up. either you get a non convex object (but this can be held back by keeping the clipped objects seperate)which complicates further actions and polygons can become non convex due to clipping or are used in non convex objects for clipping. does anyone know a good non convex polygon polygon clipper ?!
and for that manner using this type of csg in non bsp area's like portal engines ?!
Edited by - Dyad Roth on July 13, 2001 12:39:59 PM
however it still doesn't go into the actual detail of polygon/polygon clipping and does it more conveniently with convex objects. however thats al very handy but when doing a bit of combinatory boolean tech 2 things come up. either you get a non convex object (but this can be held back by keeping the clipped objects seperate)which complicates further actions and polygons can become non convex due to clipping or are used in non convex objects for clipping. does anyone know a good non convex polygon polygon clipper ?!
and for that manner using this type of csg in non bsp area's like portal engines ?!
Edited by - Dyad Roth on July 13, 2001 12:39:59 PM
That tutorial deals with brush based CSG. Like what Unreal and Quake3 use. The brushes are always convex which means that any point behind all the face planes is in the brush. This makes it relatively easy to calculate with.
Brushes make things so much easier, as they define volumes where no polygons or vertices should exist. You can''t just take two polygons and clip them because your algorithm will have no idea which part to clip or where the clipping shold stop etc...
I have never tried doing this, but there are ways of doing it I''m aware of. Basically what you need to do is split it up into convex areas first. In the BSP tree faq it describes how to do this using BSP trees, and then pushing the polygons down the tree to clip them, sorry I can''t be more specific, but have a look at the BSP tree FAQ for the full explanation, but I seriously think convex brushes and the like are the way to go.
You can create the BSP trees just for CSG, you don''t need to use them for rendering, but it would seem a bit of a waste.
I think the above is called the Naylor approach, alternatively the Laidlaw CSG approach uses just the polygon lists, but I think it is a lot more complicated, and I have never tried to use it. But it may deal with concave polygons, I''m really not too sure.
And just if you are wondering, yes I have got CSG in my engine
FatalXC
Brushes make things so much easier, as they define volumes where no polygons or vertices should exist. You can''t just take two polygons and clip them because your algorithm will have no idea which part to clip or where the clipping shold stop etc...
I have never tried doing this, but there are ways of doing it I''m aware of. Basically what you need to do is split it up into convex areas first. In the BSP tree faq it describes how to do this using BSP trees, and then pushing the polygons down the tree to clip them, sorry I can''t be more specific, but have a look at the BSP tree FAQ for the full explanation, but I seriously think convex brushes and the like are the way to go.
You can create the BSP trees just for CSG, you don''t need to use them for rendering, but it would seem a bit of a waste.

I think the above is called the Naylor approach, alternatively the Laidlaw CSG approach uses just the polygon lists, but I think it is a lot more complicated, and I have never tried to use it. But it may deal with concave polygons, I''m really not too sure.
And just if you are wondering, yes I have got CSG in my engine

FatalXC
mmh well the main problem i have with bsp''s is their inflexibility. so thats why i don''t use them
however the convex brush buildup similar to bsp is still handy.
back to the drawing board for me for CSG on objects. but do you have an example (screenshot) of your engine up by any chance? i would love to see it. and is the csg realtime or during level construction?

back to the drawing board for me for CSG on objects. but do you have an example (screenshot) of your engine up by any chance? i would love to see it. and is the csg realtime or during level construction?
My CSG is done in the compiler, with brushes imported from the Q3Radiant .map files. It basically cuts out polygons you will never see unless you are inside one of the brushes (which would never happen). I'm in the process of getting a web page up for my stuff, should be done in a few days to a week.
CSG is not very expensive to calculate, so doing it in realtime on a few objects wouldn't be too bad, I don't think.
FatalXC
Edited by - FatalXC on July 15, 2001 11:58:35 PM
CSG is not very expensive to calculate, so doing it in realtime on a few objects wouldn't be too bad, I don't think.
FatalXC
Edited by - FatalXC on July 15, 2001 11:58:35 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement