07.01.2013 Views

3D graphics eBook - Course Materials Repository

3D graphics eBook - Course Materials Repository

3D graphics eBook - Course Materials Repository

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Binary space partitioning 16<br />

together with a Z-buffer, and using the Z-buffer to correctly merge movable objects such as doors and characters<br />

onto the background scene.<br />

BSP trees are often used by <strong>3D</strong> computer games, particularly first-person shooters and those with indoor<br />

environments. Probably the earliest game to use a BSP data structure was Doom (see Doom engine for an in-depth<br />

look at Doom's BSP implementation). Other uses include ray tracing and collision detection.<br />

Generation<br />

Binary space partitioning is a generic process of recursively dividing a scene into two until the partitioning satisfies<br />

one or more requirements. The specific method of division varies depending on its final purpose. For instance, in a<br />

BSP tree used for collision detection, the original object would be partitioned until each part becomes simple enough<br />

to be individually tested, and in rendering it is desirable that each part be convex so that the painter's algorithm can<br />

be used.<br />

The final number of objects will inevitably increase since lines or faces that cross the partitioning plane must be split<br />

into two, and it is also desirable that the final tree remains reasonably balanced. Therefore the algorithm for correctly<br />

and efficiently creating a good BSP tree is the most difficult part of an implementation. In <strong>3D</strong> space, planes are used<br />

to partition and split an object's faces; in 2D space lines split an object's segments.<br />

The following picture illustrates the process of partitioning an irregular polygon into a series of convex ones. Notice<br />

how each step produces polygons with fewer segments until arriving at G and F, which are convex and require no<br />

further partitioning. In this particular case, the partitioning line was picked between existing vertices of the polygon<br />

and intersected none of its segments. If the partitioning line intersects a segment, or face in a <strong>3D</strong> model, the<br />

offending segment(s) or face(s) have to be split into two at the line/plane because each resulting partition must be a<br />

full, independent object.<br />

1. A is the root of the tree and the entire polygon<br />

2. A is split into B and C<br />

3. B is split into D and E.<br />

4. D is split into F and G, which are convex and hence become leaves on the tree.<br />

Since the usefulness of a BSP tree depends upon how well it was generated, a good algorithm is essential. Most<br />

algorithms will test many possibilities for each partition until they find a good compromise. They might also keep<br />

backtracking information in memory, so that if a branch of the tree is found to be unsatisfactory, other alternative<br />

partitions may be tried. Thus producing a tree usually requires long computations.<br />

BSP trees are also used to represent natural images. Construction methods for BSP trees representing images were<br />

first introduced as efficient representations in which only a few hundred nodes can represent an image that normally

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!