forked from jbdong/CityEngine_cga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFacade_Schematic.cga
128 lines (100 loc) · 3.67 KB
/
Facade_Schematic.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**
* File: Facade_Schematic.cga
* Created: 10 Apr 2014 19:03:04 GMT
* Author: Esri R&D Center Zurich
*/
version "2014.0"
@Hidden
import CIM_Utils:"/ESRI.lib/rules/General/CIM_Utils.cga"
###################################################
# Control Attributes
#
@Group("Facade Settings",1)
@Order(1) @Range("Random","Agricultural","Assembly","Educational","Industry","Mercantile","Office","Other","Public","Residential","Service","Transport","Unknown","Utility")
attr Usage = "Random"
@Order(2) @Range(2.7,5.5)
attr UpperfloorHeight = 3.7
@Order(3) @Range(3.1,7.5)
attr GroundfloorHeight = 4.5
@Order(4) @Range(2,10)
attr TileWidth = 3.5
@Group("Visualization Options",2)
@Order(1) @Range("grid","vertical","horizontal-open","horizontal-closed","solid")
attr Pattern = _getInitialPattern
@Order(2) @Range("Usage-driven","Blue","Grey")
attr ColorScheme = _getInitialColorScheme
@Order(3)
attr PrimaryColor = _getInitialPrimaryColor
@Order(4)
attr SecondaryColor = "#ffffff"
###################################################
# Initial attribute settings
# (to get a diversified default appeareance depending on initial shape, connection object attributes and randomness)
#
_getInitialPattern =
case Usage == "Random" : 35%: "grid" 30%: "horizontal-open" 10%: "horizontal-closed" else: "vertical"
case Usage == "Industry" : "horizontal-closed"
case Usage == "Office" : "horizontal-open"
case Usage == "Residential": "grid"
else : "vertical"
_getInitialColorScheme =
case Usage=="Random": "Grey"
else : "Usage-driven"
_getInitialPrimaryColor =
case ColorScheme=="Usage-driven": CIM_Utils.getUsageTypeColor(Usage)
case ColorScheme=="Blue" : 20%:"#7090BB" 20%:"#6080AA" 20%:"#80A0CC" 20%:"#7090AA" else:"#90A0BB"
case ColorScheme=="Grey" : 20%:"#777777" 20%:"#707070" 20%:"#808080" 20%:"#878787" else:"#909090"
else : "#000000"
########################################################################
########################################################################
###
### RULES
###
###
@StartRule
Generate -->
alignScopeToGeometry(zUp,any,world.lowest)
alignScopeToAxes(y)
FacadeElevationCheck
FacadeElevationCheck -->
case scope.elevation-initialShape.origin.py > GroundfloorHeight*0.5 # is face above ground?
|| Pattern == "vertical":
split(y){ ~1: UpperFloors | UpperfloorHeight*0.5: Wall }
else:
split(y){ GroundfloorHeight: GroundFloor | ~1: UpperFloors | UpperfloorHeight*0.5: Wall }
GroundFloor -->
case Pattern == "grid":
split(y){ '0.75: VerticalPattern | ~1: Wall }
case Pattern == "horizontal-closed":
split(x){ ~TileWidth: Wall | TileWidth*0.5: Window | ~1: Wall }
else:
Window
UpperFloors -->
case Pattern == "vertical":
VerticalPattern
case Pattern == "grid":
split(y){ ~UpperfloorHeight*0.3: Wall
| { UpperfloorHeight*0.5: VerticalPattern
| ~UpperfloorHeight*0.5: Wall }*
| UpperfloorHeight*0.5: VerticalPattern }
case Pattern == "horizontal-open":
split(y){ ~UpperfloorHeight*0.2: Wall
| { UpperfloorHeight*0.8: Window
| ~UpperfloorHeight*0.2: Wall }*
| UpperfloorHeight*0.8: Window }
case Pattern == "horizontal-closed":
split(y){ ~UpperfloorHeight*0.3: Wall
| { UpperfloorHeight*0.4: Window
| ~UpperfloorHeight*0.6: Wall }*
| UpperfloorHeight*0.4: Window }
else:
Window
VerticalPattern -->
split(x){ ~TileWidth*0.6: Wall | { TileWidth*0.7: Window | ~TileWidth*0.3: Wall }* | TileWidth*0.7: Window | ~TileWidth*0.6: Wall }
Wall -->
color(SecondaryColor)
Window -->
set(material.specular.r,0.5) set(material.specular.g,0.5) set(material.specular.b,0.5)
set(material.reflectivity,0.3)
set(material.shininess,20)
color(PrimaryColor)