Graphics Reference
In-Depth Information
1
2
3
4
5
Figure 7.21 A simple portalized world with five cells (numbered) and five portals (dashed).
The shaded region indicates what can be seen from a given viewpoint. Thus, here only cells
2, 3, and 5 must be rendered.
function is called recursively for adjoining cells whose portals are visible to the
camera. During recursion, new portals encountered are clipped against the current
portal, narrowing the view into the scene. Recursion stops when either the clipped
portal becomes empty, indicating the new portal is not visible to the camera, or
when no unvisited neighboring cells are available.
The portals are implemented as non-self-intersecting polygons. The cells them-
selves are traditionally defined by convex polyhedra. Being convex, the polygons in
the cell can be rendered in any order without risk of overlap, thus obviating the
need to sort polygons. (However, with the Z-buffer capabilities of modern hardware
convex cells are no longer a requirement.) The following pseudocode illustrates an
implementation of this rendering procedure.
RenderCell(ClipRegion r, Cell *c)
{
// If the cell has not already been visited this frame...
if (c- > lastFrameVisited != currentFrameNumber) {
// ...timestamp it to make sure it is not visited several
// times due to multiple traversal paths through the cells
c- > lastFrameVisited = currentFrameNumber;
// Recursively visit all connected cells with visible portals
for (Portal *pl = c- > pPortalList; pl != NULL; pl = pl- > pNextPortal) {
// Clip the portal region against the current clipping region
ClipRegion visiblePart = ProjectAndIntersectRegion(r, pl->boundary);
 
Search WWH ::




Custom Search