Gherkin
Travel Agent (call for special prices on Hell, Purgatory, Hades, and AGM's Bedroom)
Posts: 454
Registered: 10-01 |
Go down the BSP tree and with each split you test on which side of the split line you are. Then you continue processing that side of the tree (or the other side first if you want everything in back-tofront order) and then the other side. So you need a recursive routine.
When you reach a subsector (leaf in the tree), you test if its segs are visible. Here a one dimensional clipping buffer is perfect since Doom's map is actually only 2D. Take the angles of the wall towards the viewer and project them on the clipping buffer to test if any column (read: pixels) are visible. If so, add the subsector to a list. If non of the segs are visible, skip the subsector.
Now you have a front-to-back or back-to-front list of subsectors that you will see from your current position. I believe Doom not only keeps subsectors in this list, but also inserts other stuff like Things and maybe segs.
Im not sure how Doom renders since I wrote the rendering for DirectX, so that works very different than software rendering, but from studying its graphics it looks like this;
It takes the farthest subsector and renders each of its segs. With each seg it renders the floor and draws that in columns all the way to the bottom of the screen. Same for the ceiling, it draws from the seg all the way up to the screen. Sounds like a mess, but because it starts with the farthest, the ones closer will overdraw the 'mess' that segs in the back made.
For hardware rendering (DirectX/OpenGL) its works very different. You have to make a polygon for the ceiling and floor of each subsector and 'quad' polygones for the upper, middle and lower textures of each seg (I do this per sidedef instead of per seg, because its much faster to draw a whole sidedef at once). Because you have a Z buffer, the order of drawing doesnt matter. I draw from front to back on purpose to reduce overdraw, but transparent middle texture must still be drawn at last from back to front to keep correct transparency.
pfew, i think thats about all the basics. Im sure someone can add something to this.
__________________
Doom Connector - Your first class ticket to hell online!
Doom Builder - The cornerstone for every map author!
|