   BSP creation question.
  I have had BSP trees on my todo list for a long time, so finally got around to trying them out. I have read a lot about how to create them and understand the process fairly well.Not being very artistic I figured I'd use a map already created, base1.map from the QE4 source, part of Quake2.I have the map loaded and displaying in my editor, so far so good.What I am noticing though is some of the brushes are outside of the level, the outside of the level itself has outward facing polygons, and some brushes stick through the exterior walls.Now, am I correct in thinking these should not be there, since you could never see them once you are in the level?Then my question is, how to get rid of these and just have the visible parts of the level only?Do I create the BSP tree as is and then somehow trim off these bits?   
  The .map files don't contain any BSP information.An executable (called something like "qbsp") takes a map file and turns it in to a .bsp file, which is what Quake and Quake 2 natively read. There are differences between the Quake and Quake2 formats, but they basically have the same kind of information.Additional processes are typically run on a .bsp file too, to add lighting and PVS information. The PVS step is done by a program called something like "vis" and if I remember correctly it is this step that also what removes all the outward-facing polygons in the brushes.It's been a long time since I made any Quake levels, but I think you'll want to look at the qbsp and vis source code. I remember that there was a faster "rvis" replacement for "vis", so it might be worth hunting that down.   ;  Thank you for the response.I'm not making a quake level, or wanting to run in quake. I'm only using this map as it was available as a ready built level that I could use to create a BSP tree myself, with my code.I'll take a look at the vis code. Typically the bit I didn't look at!   ;  Before you can get propper geometry out of a quake-style MAP file and cut it up into a BSP tree, first you've got to run the CSG algorithm over the brushes in the map.The CSG step removes these "unseen" polies, checks for "leaks" (connections to the outside, from inside) resolves intersections, etc... and finally produces a polygonal mesh. It's this polygonal mesh that you want to run the BSP step on.After the BSP step, you've got a tree of areas and portals connecting those areas. This data is fed into the VIS step which computes a PVS table based on these portals. Finally you run the RAD step that computes the lightmaps for the geometry.This is all specific to quake-based game levels though. Plenty of other engines use BSP trees (or other kinds of trees) without following this kind of workflow.   ;  Ah ok, I do have to use that CSG step. Damn, I did look at the code but couldn't tell what it was doing.Guess I'll be busy implementing that and figuring out what exactly it does. There doesn't happen to be an explanation somewhere of how this works does there?   ;Quote:Original post by RabidDogAh ok, I do have to use that CSG step. Damn, I did look at the code but couldn't tell what it was doing.Guess I'll be busy implementing that and figuring out what exactly it does. There doesn't happen to be an explanation somewhere of how this works does there?Michael Abrash's Rambling in Realtime is a good read: http://www.bluesnews.com/abrash/.Just beware that it contains some outdated stuff mostly relevant for software rendering in Quake 1, but the basic CSG -> BSP -> PVS -> lighting process is the same.The CSG step is fairly easy: The most important thing is to convert the brushes of the .map file into a polygon mesh. A brush is a convex polyhedron which is defined by a number of planes (6 planes for a box, etc). During the CSG, for each brush you simply "cut" each plane of the brush by every other plane of the brush: the result is the polygons you'll use later.When you've created polygons for every brush in your map, you can basically throw the result directly at a BSP tree generator. The BSP tree you produce from this will include a lot of "outside" geometry that will never be seen, which luckily is easy to remove unless you got leaks in your level geometry. Alternatively you can do some tricks in the CSG step before making a BSP tree, but I guess the simplest approach is to just cull later in the process.[Edited by - rneckelmann on May 18, 2010 9:59:00 AM]