Hello everyone. I'm working on a project now called Doom.Net, a remake of Doom with C# and unfortunately I'm having some trouble implementing frustum culling.
Now I only need 2D culling, because while Doom levels look 3D, their structure is actually 2D. Basically the level is made up of vertices, 2D X and Z points, and line segments(two vertices connected).
I can walk through the BSP tree and get the nearest lines fine, but part of the problem is that it draws all the lines in view, so when looking at a whole level it draws everything.
My angle system looks like this:
90
|
|
180-----------0
|
|
270
My idea for culling was just to test whether any one of a lines vertices where in view, then find the angles between the camera and its vertices. I would then send those angles to some kind of clipping function, which would check if the screen was "full".
The first problem is if I have the camera looking "east" any of the retrieved angles could be between 0 and 90, while the other is between 270 and 360. I have no idea how to translate this into useable values.
Plus if the player is right in-front of a line that won't work.
\ /
*------\--/--------* Wall
\/
*Camera
Any ideas? I've been struggling with this for a while and would appreciate any help.