The canonical use of a BSP tree is for rendering polygons (that are double-sided, that is, without back-face culling) with the painter's algorithm. Such a tree is constructed from an unsorted list of all the polygons in a scene. The recursive algorithm for construction of a BSP tree from that list of polygons is:
- Choose a polygon P from the list.
- Make a node N in the BSP tree, and add P to the list of polygons at that node.
- For each other polygon in the list:
- If that polygon is wholly in front of the plane containing P, move that polygon to the list of nodes in front of P.
- If that polygon is wholly behind the plane containing P, move that polygon to the list of nodes behind P.
- If that polygon is intersected by the plane containing P, split it into two polygons and move them to the respective lists of polygons behind and in front of P.
- If that polygon lies in the plane containing P, add it to the list of polygons at node N.
- Apply this algorithm to the list of polygons in front of P.
- Apply this algorithm to the list of polygons behind P.
The following diagram illustrates the use of this algorithm in converting a list of lines or polygons into a BSP tree. At each of the eight steps (i.-viii.), the algorithm above is applied to a list of lines, and one new node is added to the tree.
|Start with a list of lines, (or in 3-D, polygons) making up the scene. In the tree diagrams, lists are denoted by rounded rectangles and nodes in the BSP tree by circles. In the spatial diagram of the lines, direction chosen to be the 'front' of a line is denoted by an arrow.|
|i.||Following the steps of the algorithm above,
|ii.||We now apply the algorithm to the list of lines in front of A (containing B2, C2, D2). We choose a line, B2, add it to a node and split the rest of the list into those lines that are in front of B2 (D2), and those that are behind it (C2, D3).|
|iii.||Choose a line, D2, from the list of lines in front of B2. It is the only line in the list, so after adding it to a node, nothing further needs to be done.|
|iv.||We are done with the lines in front of B2, so consider the lines behind B2 (C2 and D3). Choose one of these (C2), add it to a node, and put the other line in the list (D3) into the list of lines in front of C2.|
|v.||Now look at the list of lines in front of C2. There is only one line (D3), so add this to a node and continue.|
|vi.||We have now added all of the lines in front of A to the BSP tree, so we now start on the list of lines behind A. Choosing a line (B1) from this list, we add B1 to a node and split the remainder of the list into lines in front of B1 (i.e. D1), and lines behind B1 (i.e. C1).|
|vii.||Processing first the list of lines in front of B1, D1 is the only line in this list, so add this to a node and continue.|
|viii.||Looking next at the list of lines behind B1, the only line in this list is C1, so add this to a node, and the BSP tree is complete.|
The final number of polygons or lines in a tree is often larger (sometimes much larger) than the original list, since lines or polygons that cross the partitioning plane must be split into two. It is desirable to minimize this increase, but also to maintain reasonable balance in the final tree. The choice of which polygon or line is used as a partitioning plane (in step 1 of the algorithm) is therefore important in creating an efficient BSP tree.
Read more about this topic: Binary Space Partitioning
Other articles related to "generation, generations":
... The term generation is sometimes applied to a cultural movement, or more narrowly defined group than an entire demographic ... Some examples include The Beat Generation, a popular American cultural movement that most social scholars say laid the foundation of the pro-active American ... The Beat Generation is between the Silent Generation and the Baby Boomers ...
... Generation name, variously zibei or banci, is one of the characters in a traditional Chinese name, and is so called because each member of a generation (i.e ... siblings and cousins of the same generation) share that character, unlike surnames or given names ... Where used, generation names were usually given only to males, although this does vary from lineage to lineage and has changed over time ...
... Generation Type Birth years Formative era Late Medieval Saeculum Arthurian Generation Hero (Civic) 1433–1460 (27) Unraveling Retreat from France Humanist Generation ... Generation Hero (Civic) 1901–1924 (23) Unraveling World War I/Prohibition Silent Generation Artist (Adaptive) 1925–1942 (17) Crisis Great Depression ... is because according to the chart, the Civil War came about ten years too early the adult generations allowed the worst aspects of their generational personalities to come through and the ...
... Opel continued to provide the basis for future generations until the launch of the fourth generation in 2006, which deployed an Australian developed platform ... crossover were provided by the now discontinued third generation architecture ... Prior to the 1988 onwards second generation Commodore, the Holden was positioned a full class below the full-size Falcon ...
... There has been considerable debate about whether second-generation antipsychotic drugs are more effective than first-generation antipsychotic drugs ... been suggested that there is no validity to the term "second-generation antipsychotic drugs" and that the drugs that currently occupy this category are not identical to each ... do not improve specific symptoms, have no clearly different side-effect profiles than the first-generation antipsychotics, and are less cost effective ...
Famous quotes containing the word generation:
“This generation has come into the world fatally late for some enterprises. Go where we will on the surface of things, men have been there before us.... But the lives of men, though more extended laterally in their range, are still as shallow as ever.”
—Henry David Thoreau (18171862)
“One generation passeth away, and another generation cometh: but the earth abideth for ever. The sun also ariseth, and the sun goeth down, and hasteth to the place where he arose.”
—Bible: Hebrew Ecclesiastes, 1:4-5.
Ernest Hemingway took the title The Sun Also Rises (1926)
“Todays comedian has a cross to bear that he built himself. A comedian of the older generation did an act and he told the audience, This is my act. Todays comic is not doing an act. The audience assumes hes telling the truth. What is truth today may be a damn lie next week.”
—Lenny Bruce (19251966)