forked from jbdong/CityEngine_cga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimpleBuilding.01.cga
128 lines (88 loc) · 3.05 KB
/
simpleBuilding.01.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
128
/**
* File: simpleBuilding.01.cga
* Created: 4 May 2008 23:27:29 GMT
* Author: andi
*/
version "2010.3"
/* Attributes *************************************/
attr groundfloor_height = 4
attr floor_height = 3.5
attr tile_width = 3
attr height = 11
attr wallColor = "#fefefe"
/* Assets *************************************/
// geometries
window_asset = "facades/window.obj"
/* Initial Shape starting rule *************/
# scale the lit to leave a small border and extrude the lot to building height
Lot -->
extrude(height) Building
# inner lots are dropped
LotInner --> NIL
# split the building geometry into its facade components
Building -->
comp(f) { front : Frontfacade | side : Sidefacade | top: Roof}
# the front facade is subdivided into one front groundfloor
# and upper floors
Frontfacade -->
setupProjection(0, scope.xy, 1.5, 1, 1) # setup 1.5m x 1m texture tiles along scopes xy plane (and distortion in z)
setupProjection(2, scope.xy, scope.sx, scope.sy)
split(y){ groundfloor_height : Groundfloor
| {~floor_height : Floor}* }
# a side facade is subdivided into one bottom floor
# and upper floors.
Sidefacade -->
setupProjection(0, scope.xy, 1.5, 1, 1) # setup 1.5m x 1m texture tiles along scopes xy plane (and distortion in z)
setupProjection(2, scope.xy, scope.sx, scope.sy)
split(y){ groundfloor_height : Floor
| {~floor_height : Floor}* }
# each floor is horizontally split into two narrow corner areas on
# each side of the floor, and into a set of window tiles in between
Floor -->
split(x){ 1 : Wall
| { ~tile_width : Tile }*
| 1 : Wall }
# similarily, the front groundfloor is horizontally split into
# two narrow corner areas on each side of the floor,
# a special entrance tile on the right
# and into a set of window tiles in between
Groundfloor -->
split(x){ 1 : Wall
| { ~tile_width : Tile }*
| ~tile_width : EntranceTile
| 1 : Wall }
# a tile consists of a centered window element and
# wall elements above, below, left and right
Tile -->
split(x){ ~1 : Wall
| 2 : split(y){ 1: Wall | 1.5: Window | ~1: Wall }
| ~1 : Wall }
# similarily, the EntranceTile contains a centered Door element,
# but with no wall on spacing below
EntranceTile -->
split(x){ ~1 : SolidWall
| 2 : split(y){ 2.5: Door | ~2: SolidWall }
| ~1 : SolidWall }
# firstly, the depth and the depth position of the future window is set
# secondly, one of nine window textures is randomly selected
# finally, the window geometry asset is inserted
Window -->
s('1,'1,0.4)
t(0,0,-0.25)
i(window_asset)
# same for the door asset. Scaling, positioning, texture selection
# and geometry insert
# TODO: fix door uv bug (problem with uv handling on split?)
Door -->
s('1,'1,0.1)
t(0,0,-0.5)
i("builtin:cube")
# for the wall asset, setting the texture scale params u and v
# guarantees a texture mapping that nicely fits over the whole facade
Wall -->
color(wallColor)
SolidWall -->
color(wallColor)
s('1,'1,0.4)
t(0,0,-0.4)
i("builtin:cube:notex")