1.首先要拿到目标区域的建筑矢量数据
2.在City Engine中新建一个工程
工程命名
3.将建筑矢量数据导入到CityEngine中
导入建筑矢量数据
4.新建一个场景
5.将shp数据文件拖入到场景当中
6.选择所有Shapes,赋予一个建模规则
我们也可以自定义一个建模规则,下面是CityEngine中内置的规则文件,可供参考:
复制代码
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328/** * File: Building_From_Footprint.cga * Created: 20 Mar 2011 16:42:13 GMT * Updated: 10 April 2014 * Author: Esri R&D Center Zurich */ version "2014.0" @Hidden(Usage,BuildingHeight,UpperfloorHeight) import Facade_Textures:"/ESRI.lib/rules/Facades/Facade_Textures.cga" (BuildingHeight=Eave_Ht,UpperfloorHeight=Floor_Ht*unitScale,Usage=Usage) @Hidden(Usage,UpperfloorHeight) import Facade_Schematic:"/ESRI.lib/rules/Facades/Facade_Schematic.cga" (UpperfloorHeight=Floor_Ht*unitScale,Usage=Usage) import Roof_Textures:"/ESRI.lib/rules/Roofs/Roof_Textures.cga" ################################### # Attributes # @Group("Building Settings",1) @Order(1) @Range(1,400) @Description("Distance from ground to bottom of roof") attr Eave_Ht = _getInitialEaveHeight @Order(2) @Range(1,400) @Description("Distance from ground to top of roof") attr Ridge_Ht = _getInitialRidgeHeight @Order(3) @Range("Random","Agricultural","Assembly","Educational","Industry","Mercantile","Office","Other","Public","Residential","Service","Transport","Unknown","Utility") attr Usage = _getInitialUsage @Order(4) @Range("extrusion","setback top","setback facade","setback base","setback everywhere") attr Building_Form = _getInitialBuildingForm @Order(5) @Range("flat","shed","pyramid","gable","hip","half-hip","gablet","gambrel","mansard","gambrel-flat","mansard-flat","vault","dome","saltbox","butterfly") # gable & shed combinations attr Roof_Form = _getInitialRoofForm @Order(6) @Range(2.9,5.2) @Description("in Meters") attr Floor_Ht = 3.7 @Hidden attr Roof_Ht = (Ridge_Ht - Eave_Ht) * unitScale @Group("Visualization Options",2) @Order(1) @Range("realistic with facade textures","schematic facades","solid color") attr Representation = "realistic with facade textures" @Order(2) @Range(0,1) attr Transparency = 0 @Order(3) @Range(0,1) attr OverwriteColor = "#ffffff" @Group("Rule Options") @Order(2) @Range("Meters","Feet") @Description("Unit of Height Attributes") attr Unit = "Meters" ################################### # Consts # # user-driven constants const unitScale = case Unit=="Feet": 1/0.3048006096012192 else: 1 # for curved roofs such as dome or vault const curvedAngleResolution = 10 ################################### # Functions # # for curved roofs such as dome or vault calcSegmentHt(n) = Roof_Ht * (cos(n*curvedAngleResolution) - cos((n+1)*curvedAngleResolution)) _getInitialBuildingForm = case Eave_Ht*unitScale < 50 : "extrusion" case Eave_Ht*unitScale > 100: "setback everywhere" else : 5%:"extrusion" 15%:"setback top" 15%:"setback facade" 15%:"setback base" else:"setback everywhere" _getInitialUsage = case Eave_Ht>30: "Random" else: 80%:"Residential" else:"Random" _getInitialEaveHeight = case geometry.area < 100 : geometry.area/rand(5,10) case geometry.area < 1000: geometry.area/rand(15,25) case geometry.area < 7000: geometry.area/rand(10,25) else : geometry.area/rand(70,200) _getInitialRidgeHeight = case Eave_Ht<30: Eave_Ht+rand(3,6) else: Eave_Ht _getInitialRoofForm = case Ridge_Ht < Eave_Ht+1: "flat" else: 40%: "hip" 50%: "gable" else: "gambrel" ################################### ################################### # # RULES # ################################### ################################### @StartRule Generate --> cleanupGeometry(all,1) alignScopeToAxes(y) s('1,0,'1) # make it horizontal i.e. scale it flat alignScopeToGeometry(yUp, 0, longest) set(Eave_Ht,Eave_Ht*unitScale) set(Floor_Ht,Floor_Ht*unitScale) report("Footprint Area (m2)",geometry.area) report("Nbr of Floors",rint(Eave_Ht/Floor_Ht)) set(material.opacity,1-Transparency) color(OverwriteColor) Footprint ################################### # Building Mass # Footprint --> case scope.sz < 10 || scope.sx < 10: Extrusion(Eave_Ht,true,1) case Building_Form == "setback top": SetbackTop case Building_Form == "setback facade": SetbackFacade case Building_Form == "setback base": SetbackBase case Building_Form == "setback everywhere": SetbackAll else: Extrusion(Eave_Ht,true,1) SetbackTop --> split(x){ 'rand(0.1,0.3): Extrusion(Eave_Ht-rint(rand(3))*Floor_Ht,false,4) | ~1 : Extrusion(Eave_Ht,true,6) | 'rand(0.1,0.3): Extrusion(Eave_Ht-rint(rand(3))*Floor_Ht,false,4) } SetbackFacade --> split(z){ 'rand(0.03,0.2): Extrusion(Eave_Ht*rand(0.2,0.8),false,2) | ~1 : Extrusion(Eave_Ht,true,6) | 'rand(0.03,0.2): Extrusion(Eave_Ht*rand(0.2,0.8),false,2) } SetbackBase --> [ extrude(3*Floor_Ht) Mass(false) ] t(0,3*Floor_Ht,0) split(x){ 'rand(0.6,0.8): Extrusion(Eave_Ht-3*Floor_Ht,true,6) } SetbackAll --> [ extrude(3*Floor_Ht) Mass(false) ] t(0,3*Floor_Ht,0) set(Eave_Ht,Eave_Ht-3*Floor_Ht) split(x){ 'rand(0.6,0.8): split(z){ '0.2: Extrusion(Eave_Ht*rand(0.2,0.8),false,2) | ~1 : SetbackTop | '0.2: Extrusion(Eave_Ht*rand(0.2,0.8),false,2) } } Extrusion(height,constructRoof,maxLength) --> convexify(maxLength) comp(f){ all: alignScopeToGeometry(yUp, 0, longest) ExtrusionConvexified(height,constructRoof,maxLength) } ExtrusionConvexified(height,constructRoof,maxLength) --> case scope.sx < maxLength+1 || scope.sz < maxLength+1: NIL else: report("Gross Floor Area (m2)",geometry.area*rint(height/Floor_Ht)) extrude(height) Mass(constructRoof) Mass(constructRoof) --> case constructRoof: comp(f){side : Facade | top : Roof } else: comp(f){side : Facade | top : RoofPlane } ################################### # Roof Generation # Roof --> case Roof_Form == "shed" : ShedRoof case Roof_Form == "pyramid" : PyramidRoof case Roof_Form == "gable" : GableRoof case Roof_Form == "hip" : HipRoof case Roof_Form == "half-hip" : HalfHipRoof case Roof_Form == "gablet" : GabletRoof case Roof_Form == "gambrel" : GambrelRoof case Roof_Form == "mansard" : MansardRoof case Roof_Form == "gambrel-flat": GambrelFlatRoof case Roof_Form == "mansard-flat": MansardFlatRoof case Roof_Form == "vault" : VaultRoof case Roof_Form == "dome" : DomeRoof case Roof_Form == "saltbox" : SaltboxRoof case Roof_Form == "butterfly" : ButterflyRoof else : FlatRoof # basic roof types ShedRoof --> roofShed(15) RoofMassScale GableRoof --> roofGable(45,0,0,false,0) RoofMassScale HipRoof --> roofHip(45) RoofMassScale PyramidRoof --> roofPyramid(45) RoofMassScale # gable & hip combinations HalfHipRoof --> roofGable(45,0,0,false,0) s('1,Roof_Ht,'1) # creates a gable roof and sets its height to the given roof height split(y){ '0.5: RoofMass(true) # ... comp(f){ bottom: NIL | horizontal: set(Roof_Ht,Roof_Ht*0.5) HipRoof } } # ... and invokes a hip roof on the top GabletRoof --> roofHip(45) s('1,Roof_Ht,'1) split(y){ '0.5: RoofMass(true) comp(f){ bottom: NIL | horizontal: set(Roof_Ht,Roof_Ht*0.5) GableRoof } } # gable/hip double-pitched GambrelRoof --> roofGable(70,0,0,false,0) split(y){ Roof_Ht*0.7: RoofMass(true) comp(f){ bottom: NIL | horizontal: set(Roof_Ht,Roof_Ht*0.3) GableRoof } } MansardRoof --> roofHip(70) split(y){ Roof_Ht*0.7: RoofMass(true) comp(f){ bottom: NIL | horizontal: set(Roof_Ht,Roof_Ht*0.3) HipRoof } } # gable/hip with flat top GambrelFlatRoof --> roofGable(45,0,0,false,0) split(y){ Roof_Ht: RoofMass(false) } MansardFlatRoof --> roofHip(45) split(y){ Roof_Ht: RoofMass(false) } # round roofs VaultRoof --> VaultRoof(90/curvedAngleResolution-1) VaultRoof(n) --> case n > 0: roofGable(n*curvedAngleResolution,0,0,false,0) split(y){ (calcSegmentHt(n)): RoofMass(n!=1) comp(f){ bottom: NIL | horizontal: VaultRoof(n-1) } } else: NIL DomeRoof --> DomeRoof(90/curvedAngleResolution-1) DomeRoof(n) --> case n > 0: roofHip(n*curvedAngleResolution) split(y){ (calcSegmentHt(n)): RoofMass(n!=1) comp(f){ bottom: NIL | horizontal: DomeRoof(n-1) } } else: NIL # gable & shed combinations SaltboxRoof --> roofShed(45) s('1,1.5*Roof_Ht,'1) split(y){ '0.333: RoofMass(true) comp(f){ bottom: NIL | horizontal: set(Roof_Ht,Roof_Ht*0.5) roofGable(45,0,0,false,geometry.nVertices-1) RoofMassScale } } ButterflyRoof --> split(y){ '0.5: roofShed(45,geometry.nVertices/2) RoofMassScale | '0.5: ShedRoof } # flat roof FlatRoof --> case Roof_Ht > 0.1: RoofPlane offset(-0.4,border) extrude(Roof_Ht) RoofMass(false) else: RoofPlane # roof volume RoofMassScale --> s('1,Roof_Ht,'1) RoofMass(false) RoofMass(removeBottomAndTop) --> case removeBottomAndTop: comp(f){ horizontal: NIL | vertical: Facade | all: RoofPlane } else: # remove only the bottom face comp(f){ bottom: NIL | vertical: Facade | all: RoofPlane } ################################### # Surface Texturing & Coloring # RoofPlane --> case Representation == "realistic with facade textures": Roof_Textures.Generate else: SolidColor Facade --> case Representation == "realistic with facade textures": Facade_Textures.Generate case Representation == "schematic facades": case OverwriteColor == "#ffffff": Facade_Schematic.Generate else: set(Facade_Schematic.SecondaryColor,OverwriteColor) Facade_Schematic.Generate else: SolidColor SolidColor --> color(OverwriteColor)
7.点击Generate,根据建模规则生成建筑模型
8.导出.fbx格式文件
9.将导出的.fbx文件连同贴图一起导入到Unity中
10.将模型放到场景中查看效果
最后
以上就是无心水池最近收集整理的关于Unity & CityEngine 根据地图中建筑矢量数据批量建模的全部内容,更多相关Unity内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复