Skip to main content
gamedev.net
🔒 Locked

BSP Question

Started by Blah2 2 replies 1k views
Original Post
Blah2
Blah2
Hi, I''m trying to write a 3d level editor and a BSP compiler, so that I can understand how they work. However, even after looking at the source for the Quake level editing tools, I''m still a little confused. I read Michael Abrash''s Graphics Programming Black Book, and he said, "When the BSP is built, the outer surfaces of the level, which no one can ever see, are removed...". How is this done? How does the BSP compiler know the difference between a face that is inside the level, and a face that is on the outside? Thanks in advance! ----Blah
Spellbound
Spellbound
After you have built the BSP tree, you can easily find the faces that are on the outside by drawing a line from a point that is known to be outside the structure (outside the bounding box) through one of the surfaces of the tree. The surface that is closest to the starting point is also a surface that is outside the level. Once you have found one surface on the outside hull all surfaces that are directly in contact with that will also be on the outside hull. You need to be careful though, because if you have a hole in your map everything will be removed.

You may also want to take a look at An Investigation into Real-time 3D Polygon Rendering using BSP Trees
Blah2
Blah2
Thanks for the quick reply, but I still have some
questions. First of all, are you sure this is the right
way? I don''t see where this is done in Id Software''s
BSP compiling code.... (I''m not saying that it''s not in
there, just that I have been unable to find it

Second, does ''directly in contact'' mean that one face is
touching another? Because if that''s the case, what about
this problem: I have a cube made out of 6 brushes, each of
those brushes having 6 faces, and the contents of the
brushes are all set to CONTENTS_SOLID. (This is kind of
hard to describe, but you would see what I''m talking about
as soon as you loaded up a map editor and made a simple
room) If I find one face on the outside, that face touches
a face next to it, which touches a face that is on the
inside. So if I remove the outside face and all faces
touching it, I would eventually remove the inside faces
too. Not because there are any leaks, but because some of
the inside faces are touching faces which touch outside
faces.

I hate to ask such a big favor, but if you (or anyone else)
could point out the place in some source code (like Id''s
tools, Genesis 3d''s tools, etc) where the surfaces I''m
talking about are removed, or just tell me what phase of
the build process it takes place in (like after the tree
is built, or after the portals are found, etc), that would
REALLY help me out! But I realize that''s a big favor, so
if you don''t have the time or the desire, please just
ignore it. Thanks for reading

----Blah









Spellbound
Spellbound
Unfortunately I don''t have any sourcecode to show you, and I haven''t looked into id Software''s Quake code so I don''t know where or even if it does this.

For your question about ''directly in contact''. Two surfaces are only in contact if their edges are in contact. This doesn''t solve the problem that you stated, but if you add the condition that a surfaces may only share an edge with one other surface it can be solved. Now it is instead a problem of choosing which surfaces that should share edges and here you should choose the ones that gives that smallest angle between the them. The two surfaces that face each other has an angle of zero between them so this pair is connected, leaving the two other surfaces for each other.


/ /
/ /
/ /
----+---+ <- This is the origin of the problem
/
--------+


If you do this test after the making of the portals you should already have removed the two surfaces that are facing each other since it is a cell with no volume.

I hope I could shed some light upon your worries.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.