forked from jbdong/CityEngine_cga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimpleBuildingShells_03.cga
110 lines (75 loc) · 2.1 KB
/
simpleBuildingShells_03.cga
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**
* File: simpleBuildingShells.cga
* Created: 14 Jul 2008 16:03:27 GMT
* Author: andi
*/
version "2012.1"
// height value
attr height =80
// land use types
attr t_industrial = 0
attr t_commercial = 0
attr t_residential = 0
// color declarations
red = "#ffaaaa"
green = "#aaffaa"
blue = "#aaaaff"
white = "#ffffff"
// Functions
landuseTypeColor =
case t_industrial > t_commercial && t_industrial > t_residential : red
case t_commercial > t_industrial && t_commercial > t_residential : blue
case t_residential > t_industrial && t_residential > t_commercial : green
else : white
// calc height with variation
getHeight(area) =
case area > 600 : rand(0,40)+height
case area > 200 : rand(0,40)+height/2
else: rand(15,30)
## Rules
Lot -->
// prepare building ground size and pivot orientation
case geometry.isConcave : color(landuseTypeColor)LotSub(getHeight(geometry.area))
else : color(landuseTypeColor) s('.8,'1,'.8) center(xz) LotSub(getHeight(geometry.area))
LotInner --> Lot
LotSub(h) -->
// trigger building rules depending on lot polygon
case geometry.isRectangular(10) :
case scope.sx-10 < scope.sz && scope.sx+10 > scope.sz:
RectQuad(h)
else:
Rect(h)
else:
Gen(h)
RectQuad(h) -->
case h > 30 : s('.8,'1,'.8) center(xz) extrude(h) UShaped
else : extrude(h) House
Rect(h) -->
case h > 30 : extrude(h) LShaped
else : extrude(h) House
Gen(h) -->
case h > 60 : extrude(h) Tower
else : extrude(h) Facades
// U-Shaped
UShaped -->
split(x){ 'rand(.3,.5): Facades | ~1: SideWings }
SideWings -->
split(z){ 'rand(.3,.45): SideWing | ~1: NIL | 'rand(.3,.45): SideWing }
SideWing -->
30% : Facades
30% : split(x){ 'rand(0.2,0.8) : Facades }
else : s('1,'rand(0.2,0.9),'1) Facades
// L-Shaped
LShaped -->
split(x){ 'rand(.3,.5): Facades | ~1: SideWings }
Tower -->
case scope.sy > 5 :
s('0.9,'1,'0.9) center(xz) split(y){ '0.3 : Element. | '0.7 : Tower }
else :
NIL
House -->
comp(f){top : Roof | side : Facades}
Roof --> roofPyramid(30) comp(f){bottom : NIL | all : RoofTop}
// no building details an roof and facades
Facades --> X.
RoofTop --> X.