-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathStreet_Modern_Simple.cga
83 lines (57 loc) · 3.64 KB
/
Street_Modern_Simple.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
/**
* File: Street Construction Simple.cga
* Created: 1 April 2014
* Author: Esri R&D Center Zurich
*/
version "2014.0"
@Order(1) @Range(0,4)
attr NbrOfRightLanes = _getInitialRightLanes
@Order(2) @Range("yellow","white","none")
attr Centerline = "yellow"
# Typically, the width values are overriden by the shape parameters, however in case no shape parameters are available (e.g. on Junction or Freeway shapes of nodes), the texture coordinates contain the needed values
@Hidden @Order(3) @Range(3.5,30)
attr streetWidth = geometry.dv(0,unitSpace) # REALWORLD-distance in V-direction corresponds to width of street (in case the geometry does not contain rounded entry geometry)
@Hidden @Order(4) @Range(1,6)
attr laneWidth = streetWidth/geometry.dv(0,uvSpace) # note that TEXTURE-distance in V-direction corresponds to number of lanes (as generated by CityEngine)
const TextureFolder = "Streets/"
const SidewalkHeight = 0.2 # height of sidewalk (and depth of curbs)
const nLanesTotal = rint(streetWidth/laneWidth)
const oneWay = NbrOfRightLanes<=0 || NbrOfRightLanes>=nLanesTotal
_getInitialRightLanes = case nLanesTotal>2: rint(nLanesTotal/2+0.01)
else : 30%: rint(nLanesTotal/2) 40%: nLanesTotal else: 0 # adding some randomness to get a more diversified default appeareance
# RULES
@StartRule
Street --> # split away the side geometry on the streets
split(v,uvSpace,0){ -geometry.vMin: Asphalt # the lanes start at v-coord 0 i.e. everything below can be splitted away (= asphalt)
| nLanesTotal : Lanes # the lanes end at v-coord nLanesTotal
| ~1 : Asphalt } # all remaining geometry beyond v-coord nLanesTotal can be split away
Lanes -->
case Centerline=="none" || oneWay: # LANE WITHOUT CENTERLINE: these textures can be repeated also in v-direction, i.e. every lane contains ONE edge line on the texture
scaleUV(0,1,nLanesTotal*256/(nLanesTotal*256+18)) # v-coord: texture image has 4 lanes (see above*)... and getting rid of the repeating edge line by cutting away a part of the texture (one lane is 256 px in the texture and a line is 18 px wide))
LanesTexture("lanes_4_stripes_white_14x14m.jpg",4)
else: # LANE WITH CENTERLINE: note that centerline is a double line - this influence the mapping method (pls compare with the non-centerline case below)
translateUV(0,0,4-NbrOfRightLanes) # number of lanes which the texture (with its 8 lanes) must be translated (in v-dir) so that its center is placed on street center
LanesTexture("lanes_8_centerline_"+Centerline+"_14x28m.jpg",8)
LanesTexture(texFile,texNLanes) -->
tileUV(0,~14,0) # the tileUV operation makes sure that one unit in u-space corresponds to approx 14 meters, the v-coord is not touched in the case of 0 as parameter
scaleUV(0,1,1/texNLanes) # scaling the v coord for the texture (e.g. a street with 2 lanes has v coords from 0 to 2, this means it has to map onto 0 to 2/8 on our texture with its 8 lanes)
texture(TextureFolder + "Lanes/" + texFile)
Asphalt -->
tileUV(0,14,14) texture(TextureFolder + "Lanes/asphalt_14x14m.jpg")
# Other default Start Rules for Network Shapes
Joint --> Lanes
Junction --> Lanes
Freeway --> Lanes
FreewayEntry --> Lanes
Crossing --> Asphalt
Roundabout --> Asphalt
RoundaboutIsland --> Asphalt
# Sidewalk
Sidewalk -->
split(v,unitSpace,0){ SidewalkHeight: Curbs | ~1: Pavement }
Curbs -->
extrude(world.y,SidewalkHeight)
tileUV(0,~2,'1) texture(TextureFolder + "Sidewalks/curbs_2m.jpg")
Pavement -->
translate(rel,world,0,SidewalkHeight,0)
tileUV(0,~2,'1) texture(TextureFolder + "Sidewalks/pavement_01_2x2m.jpg")