BSP Tree

../../../_images/bsp.png

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 null

Link to subareas with draw-obj

property padding: INTEGER;
Default 0

Padding between subareas.

../../../_images/bsp-p-5.png

padding: 5

../../../_images/bsp-p-20.png

padding: 20

property justify: JUSTIFY-X, JUSTIFY-Y | center | random;
Default start, start

Align of body element.

../../../_images/bsp-j-start.png

justify: start, start

../../../_images/bsp-j-end.png

justify: end, end

../../../_images/bsp-j-center.png

justify: center

../../../_images/bsp-j-random.png

justify: random

property iterations-count: INTEGER;
Default 3

How 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) ** 2 where ** is a power operator

If 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.

../../../_images/bsp-i-1.png

iterations-count: 1

../../../_images/bsp-i-2.png

iterations-count: 2

../../../_images/bsp-i-3.png

iterations-count: 3

../../../_images/bsp-i-4.png

iterations-count: 4

property min-width: INTEGER;
Default 0

If width of subarea (+ padding) is smaller than min-width then splitting will be stopped.

property min-height: INTEGER;
Default 0

If height of subarea (+ padding) is smaller than min-height then splitting will be stopped.

property max-width: INTEGER;
Default width of subarea

If 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 subarea

If 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