car parks

648
3
05-19-2013 11:00 PM
gulhunduran
New Contributor
Hi!
I want to create on road car parks in CityEngine. I'm planning to modify modernstreets.cga file. What am I supposed to do??
0 Kudos
3 Replies
JoanneO_Brien
Occasional Contributor
It depends on the sort of carparks you want, but if you want something like in the attached image, I modified the Street Construction cga. This originally allowed you to have green spaces on the edge, but I changed these to be carparks eg:

# -----------------------
#Carparks Attributes
@Group("Carpark",3) @Order(1) 
attr carparks = false

@Group("Carpark") @Order(2) 
attr carparkwidth = 2.5
# -----------------------
# Sidewalk Attributes

@Group("Sidewalk") @Order(3) @Range(0,0.4)
attr Sidewalk_height = 0.2  # height of sidewalk (and depth of Kerbs)

@Group("Sidewalk") @Order(4) @Range("grey asphalt","pavement")
attr sidewalk_style = "grey asphalt"
# ----------------------------------------
# Functions
# ----------------------------------------
calcNbrOfLanes = rint(lenAlongV/ Lane_width )  
calcLanesLeft  = rint((lenAlongV*0.5-Median_width) / Lane_width)  
calcLanesRight = rint((lenAlongV - calcLanesLeft*Lane_width - Median_width) / Lane_width) 

lenAlongU = geometry.du(0,unitSpace)  # for convenience and readability only
lenAlongV = geometry.dv(0,unitSpace)  # for convenience and readability only

@StartRule
Street --> 
 alignScopeToAxes(y)
 split(u,unitSpace,0){ Crosswalk_width *conStart : Crosswalk(-1) 
    | ~1                                : Streetsides
    | Crosswalk_width *conEnd           : Crosswalk(1) } 
 BridgeMain

# create left and right side of the street (per default same nbr of lanes in both directions, but user can influence it via attributes)
# modified for New Zealand roads
Streetsides -->
    case calcNbrOfLanes < 1.1 : Asphalt
    case Nbr_of_left_lanes == 0 && Nbr_of_right_lanes == 0:
        split(v,unitSpace,0){ ~calcLanesLeft          : scaleUV(0,-1,-1) Lanes(calcNbrOfLanes,connectionStart,2) Vehicles(2) 
                            | Median_width            : Median
                            | ~calcLanesRight         : Lanes(calcNbrOfLanes,connectionEnd,0) Vehicles(0)}
    else:
        split(v,unitSpace,0){ ~Nbr_of_left_lanes    : scaleUV(0,-1,-1) Lanes(Nbr_of_left_lanes,connectionStart,2) Vehicles(2)
                            | Median_width            : Median
                            | ~Nbr_of_right_lanes    : Lanes(Nbr_of_right_lanes,connectionEnd,0) Vehicles(0) }


# Lanes
Lanes(nLanes,connectionType,dir) --> 
 case connectionType == "STREET" || lenAlongU < 10:
  Asphalt("stripes",nLanes) 
 case connectionType == "JUNCTION" && type == "MAJOR": 
  Asphalt("stripes",nLanes)
 else: 
  split(u,unitSpace,0){ ~1  : Asphalt("stripes",nLanes) 
    |  12 : Asphalt(arrows,nLanes) }

# Asphalt
# - with lanes
Asphalt(type,nLanes) -->
 case lenAlongU > 3:
  [ extrude(0.1) comp(f){all: NIL} ] // required for occlusion check
  normalizeUV(0, uv, collectiveAllFaces) 
  scaleUV(0,0.5*rint(lenAlongU/6),1)
  texture(getStreetTexture(type,nLanes))
  Asphalt.
 else:
  Asphalt

# - no lanes
Asphalt -->
 [ extrude(0.1) comp(f){all: NIL} ] // required for occlusion check
 setupProjection(0, world.xz, 12, 9) projectUV(0)
 texture(concrete_tex)
 Asphalt.
 
# ----------------------------------------
# Sidewalk
# ----------------------------------------

Sidewalk --> 
 alignScopeToAxes(y) 
 SidewalkWithKerbs 
 t(0, Sidewalk_height ,0)
 
SidewalkWithKerbs --> 
 case carparks == true :
 comp(f){ top   : split(y){ Sidewalk_height : CarparkKerbs | ~1 : CarparkPavement } }
        else: 
 extrude(world.y, Sidewalk_height )
 comp(f){ top : split(y){ Sidewalk_height : Kerbs | ~1 : CarparkPavement }|
         side : Kerbs}
         

# ----------------------------------------
# Rules needed by all
# ----------------------------------------
 
SolidKerbs -->
 extrude(world.y, Sidewalk_height ) 
 comp(f){ top: alignScopeToGeometry(zUp,1) Kerbs | side: Kerbs } 

SolidKerbsNormal -->
 extrude(Sidewalk_height) 
 comp(f){ top: alignScopeToGeometry(zUp,1) Kerbs | side: Kerbs } 

CarparkKerbs-->  
 case carparks == true: 
  split(x){Crosswalk_width*2 : extrude(world.y, Sidewalk_height )Kerbs
  | ~1 : t(0,carparkwidth,0) extrude(Sidewalk_height)Kerbs | Crosswalk_width*2 : extrude(world.y, Sidewalk_height )Kerbs}
  setupProjection(0,scope.xy,~1.1,'1) projectUV(0) 
  texture(kerb_tex)
 else:Kerbs
 
Kerbs --> 
  case scope.sx < 0.5:
   setupProjection(0,scope.xy,1,'1) projectUV(0) 
   translateUV(0,-scope.sx/2,0)
   texture(kerb_tex)
  else:
   setupProjection(0,scope.xy,~1.1,'1) projectUV(0) 
   texture(kerb_tex)

CarparkPavement -->
 case carparks == true : 
  split(u,unitSpace,0){ Crosswalk_width*2 : extrude(world.y, Sidewalk_height )Pavement 
   | t(0,-0.2,0) split(v,unitSpace,0)
   { carparkwidth : split(u,unitSpace,0){0.2 : extrude(Sidewalk_height)Kerbs 
   |{ ~5 : Asphalt  | { ~0.1:  WhiteLine | ~5 : Asphalt }* |0.2 : extrude(Sidewalk_height)Kerbs} } 
   |  ~1 : t(0,0.2,0) extrude(world.y, Sidewalk_height )Pavement }
   | Crosswalk_width*2: extrude(world.y, Sidewalk_height )Pavement }
  else: Pavement


Pavement -->
 alignScopeToGeometry(zUp, 0,0)
 Pavement(rand(10),rand(10)) 

Pavement(texUOffset,texVOffset) -->
 setupProjection(0,scope.xy,1,1,texUOffset,texVOffset) projectUV(0)
 setupProjection(2,scope.xy,100, 100) projectUV(2)
 texture(sidewalk_tex)set(material.dirtmap, swdirtmap)
 
WhiteLine-->    
 color(White)


That's just parts of the code relating to the carparks but I hope that gives you some idea's anyway.
0 Kudos
gulhunduran
New Contributor
Thats exactly what I'm looking for, thank you for your help!!
0 Kudos
by Anonymous User
Not applicable
Great post. Glad to see this.

We've just released a new example that has exactly what you are talking about:
http://www.arcgis.com/home/item.html?id=747c5e4fb4af48408bb15b441ce38c9f

Just as you suggested, the street rules in the Redlands example are an evolution of the previous street rules. You can do this yourself, and make wonderful new variations, which we'd love to see. Or if you just need basic parallel or 60 degree angled parking, we've built those options in the Redlands streets rules. It also supports bike lanes and reversed traffic direction amongst other options.

Let us know where else to take the streets, or if you have new variations to share.

Chris
0 Kudos