BSP Tree¶
BSP means Binary Space partitioning. It’s an advanced container which parts area into smaller areas randomically.
The algorithm of partitioning is here: http://www.roguebasin.com/index.php?title=Basic_BSP_Dungeon_generation
Properties¶
-
property
display:bsp-tree; Required YES
-
property
body:DRAW-OBJ-SELECTOR; Default nullLink to subareas with draw-obj
-
property
justify:JUSTIFY-X, JUSTIFY-Y | center | random; Default start, startAlign of body element.
justify: start, start¶
justify: end, end¶
justify: center¶
justify: random¶
-
property
iterations-count:INTEGER; Default 3How many iterations will be executed to parts area into two smaller areas. Each iteration split each area to two smaller areas (vertically or horizontally). Max number of areas is
(iterations-count - 1) ** 2where**is a power operatorIf area is too small to split (with min-width and min-height) then splitting will be stopped.
If iteration is greater than iterations-count and width of area is greater than max-width (or vice-versa with height), then area should split into two areas again.
iterations-count: 1¶
iterations-count: 2¶
iterations-count: 3¶
iterations-count: 4¶
-
property
min-width:INTEGER; Default 0If width of subarea (+ padding) is smaller than min-width then splitting will be stopped.
-
property
min-height:INTEGER; Default 0If height of subarea (+ padding) is smaller than min-height then splitting will be stopped.
-
property
max-width:INTEGER; Default width of subareaIf iteration is greater than iterations-count and width of area if greater than max-width, then area should split into two areas again.
-
property
max-height:INTEGER; Default height of subareaIf iteration is greater than iterations-count and height of area if greater than max-height, then area should split into two areas again.
Example¶
district {
display: bsp-tree;
body: house;
iterations-count: 4;
padding: 10;
justify: center;
width: 500;
depth: 500;
min-width: 100;
min-height: 100;
}
You can try on https://pixelopolis.herokuapp.com/examples/Containers/Bsp-tree