Engine
Pipelines
Main engine loop is: 1 - keyboard input - detect if program must terminate, set a viewer move direction vector and viewer rotation angles; 2 - detect collision - can change the move directon vector or make portal crossing detection; 3 - update viewer reference system 4 - make sockets communication - send viewer position and receive objects position; 5 - render frame 6 - goto step 1. Rendering pipeline overview: Before rendering, must be already defined, the start sector - sector where viewer is and, the clip edge buffer, must be initialized with viewport limits. The main rendering steps are: 1 - transform sector mesh to camera reference system; 2 - project and ajust mesh to viewport; 3 - for each polygon: 3.1 - copy projected polygon vertexes to an array and count how much of them are behing near Z clip plan or outside viewport (only horizontal or vertical) limits. 3.2 - if the polygon is completety outside the viewer area skip polygon, goto step 3; 3.3 - make backface culling (usefull to avoid engine deathlock and remove some invisible polygons). The engine deathlock happens when a previous rendered sector is rendered again. Recursively, is called the render algorithm from a destin sector to a previous sector. If polygon not visible, goto step 3; 3.4 - create a new clipped polygon, if polygon intersect near Z clip plan; 3.5 - verify if the polygon is a portal 3.6 - if is a portal: set a new clip edge buffer for the destin sector, verify if some portal part is visible. If yes, call recursively the rendering (goto step 1). Before end rendering the destin sector, is needed make steps 1 and 2 again for the current sector. 3DFC v0.0.1 use the same structure, for all redendered meshes, to store camera and projected data. On next versions this would change. if the polygon is not a portal: render a textured polygon making portal clip.