Keep in mind that I may be wrong with some of the algorithms used for generating buildings. (I haven't checked my scripts, which implemented large subsets of them, but never were fully realized as an aggregation of them all, but I'm sure this works.)
There is several observations which may be noted from them.
* They tend to follow a pattern
* Those patterns repeat in a set of some sorts
* This pattern can be formulated on a set of logic conditions
In more concrete terms, there is lots of columns, walls and floor levels/stories.
5x5 will be used to better demonstrate how it is.
If we represent the columns, they may be represented as some sort of an array. (2D array.)
Code: Select all
0 1 2 3 4
0[][][][][]
1[] []
2[] []
3[] []
4[][][][][]
The corners of the buildings can or may use "special" handling for better structural or visual effects.
The way walls are added are that they are in between the columns.
Walls can start as the from the first column until just one before the last column.
Which results in the following:
Code: Select all
[]-[]-[]-[]-[]
Code: Select all
if [0][]
if [4][]
if [][0]
if [][4
]
Special handling can be done with something similar to the following:
Code: Select all
if [0][0]
if [4][0]
if [0][4]
if [4][4]
Which in short is doing a loop and changing the z axis on each loop.
So you get something like this:
Code: Select all
for (z = 0, z <= twenty; z++)
buildfloor(z);
Code: Select all
floors (for z)
(for x)
(for y)
if ([x] == 0 || [x] == 4)
buildcolumns()
if ([y] == 1 || [y] == 3)
buildcolumns()
if ([x] >= 0 && [x] <= 3)
buildwall()
if ([y] >= 0 && [y] <= 3)
buildwall()
-Zehra