// Source: peyep 官方 demo 回填(原始 cityengine 规则)· https://www.peyep.com/#/demo/facadebuilding-textured-20260929 version "2025.1" /* Attributes *************************************/ @Group("Building",1) @Range(min=5, max=40, restricted=false) attr height = 24 @Group("Floor",2) @Range(min=3, max=6, restricted=false) attr groundfloor_height = 5.5 @Group("Floor") @Range(min=3, max=6, restricted=false) attr floor_height = 4.5 @Group("Tile",3) @Range(min=2, max=5, restricted=false) attr tile_width = 3.1 @Group("Tile") @Color attr wallColor = "#ffffff" @Group("Tile") @Range(min=1, max=3, restricted=false) attr window_width = 1.4 @Group("Tile") @Range(min=1, max=3, restricted=false) attr door_width = 2.1 /* Assets *************************************/ # Geometries const window_asset = "facades/elem.window.frame.obj" const round_wintop_asset = "facades/round_windowtop.obj" const tri_wintop_asset = "facades/triangle_windowtop.obj" const halfarc_asset = "facades/arc_thin.obj" const ledge_asset = "facades/ledge.03.twopart_lessprojection.obj" const modillion_asset = "facades/ledge_modillion.03.for_cornice_ledge_closed.lod0.obj" # Textures const wall_tex = "facades/textures/brickwall.jpg" const wall2_tex = "facades/textures/brickwall_bright.jpg" const dirt_tex = "facades/textures/dirtmap.15.tif" const doortop_tex = "facades/textures/doortoptex.jpg" /* Functions *************************************/ # this function will return the requested texture string # of the type facade/window.x.tif randomWindowTex = fileRandom("*facades/textures/window.*.jpg") randomDoorTex = fileRandom("*facades/textures/doortex.*.jpg") const wall_inset = 0.4 ################################# @StartRule Lot --> primitiveQuad(32,17) shapeL(9, 5){ shape : Shape | remainder : Remainder } Shape--> extrude(height) Building # we only need the front face for this example Building --> comp(f) { side : FrontfacadeTex|top:topfacade} topfacade--> setupProjection(0, scope.xy, 2.25, 1.5, 0, 0, 1) setupProjection(2, scope.xy, '1, '1) //Frontfacade texture(wall2_tex) FrontfacadeTex --> setupProjection(0, scope.xy, 2.25, 1.5, 0, 0, 1) setupProjection(2, scope.xy, '1, '1) Frontfacade Frontfacade --> split(y){ groundfloor_height : Floor(split.index) | floor_height : Floor(split.index) | floor_height : Floor(split.index) | {~floor_height : Floor(split.index)}* | floor_height : Floor(999) | 0.5 : s('1,'1,0.3) LedgeAsset} Floor(floorindex) --> case floorindex == 0 : // Groundfloor has tiles only, no ledges Subfloor(floorindex) case floorindex == 2 : // because windows start at floor level, no bottom ledge for second floor // but balcony instead split(y){~1 : Subfloor(floorindex) Balcony | 0.5 : TopLedge} else : // all other floors have bottom ledge, tile and top ledge area split(y){1 : BottomLedge(floorindex) | ~1 : Subfloor(floorindex) | 0.5 : TopLedge} Subfloor(floorindex) --> split(x){ 0.5 : Wall(1) | { ~tile_width : Tile(floorindex) }* | 0.5 : Wall(1) } # a tile consists of a centered window element and # wall elements left and right. Tile(floorindex) --> case floorindex == 0 : // the groundfloor has different dimensions and different shapes split(x){ ~1 : SolidWall | door_width : DoorTile | ~1 : SolidWall } else : split(x){ ~1 : Wall(getWalltype(floorindex)) | window_width : WindowTile(floorindex) | ~1 : Wall(getWalltype(floorindex)) } # ---------------------------------------- # Windows # ---------------------------------------- WindowTile(floorindex) --> case floorindex == 1 || floorindex == 999: Window case floorindex == 2 : Window t(0,'1,0) WindowOrnamentRound else : Window WindowLedge t(0,'1,0) WindowOrnamentTriangle # set dimensions for the triangle window element and insert it WindowOrnamentTriangle --> s('1.7, 1.2, 0.3) center(x) i(tri_wintop_asset) Wall(0) # set dimensions for the triangle window element and insert it WindowOrnamentRound --> s('1.7, 1.2, 0.4) center(x) i(round_wintop_asset) Wall(0) split(x){~1 : WindowMod | window_width : NIL | ~1 : WindowMod } WindowMod --> s(0.2,'1.3,'0.6) t(0,'-1,0) center(x) i(modillion_asset) Wall(0) WindowLedge --> s('1.5, 0.2, 0.1) t(0,-0.2,0) center(x) primitiveCube() Wall(0) Window --> s('1,'1,0.2) t(0,0,-0.2) t(0,0,0.02) [ i(window_asset) Wall(0) ] Glass Glass --> setupProjection(0,scope.xy, '1, '1) projectUV(0) texture(randomWindowTex) set(material.specular.r, 1) set(material.specular.g, 1) set(material.specular.b, 1) set(material.shininess, 4) # ---------------------------------------- # Door # ---------------------------------------- DoorTile --> split(y){~1 : Door | scope.sx/2 : Arcs | 0.5 : Arctop} # Adds wall material and a centered modillion Arctop --> Wall(1) s(0.5,'1,0.3) center(x) i(modillion_asset) Wall(1) # Arcs --> s('1,'1,wall_inset) t(0,0,-wall_inset) Doortop primitiveCube() split(x){ ~1 : ArcAsset | ~1 : r(0,0,-90) t('-1,0,0) ArcAsset} Doortop --> setupProjection(0, scope.xy, '1, '1) texture(doortop_tex) projectUV(0) # inserts the actual arc asset ArcAsset --> i(halfarc_asset) Wall(1) Door --> t(0,0,-wall_inset) setupProjection(0,scope.xy, '1, '1) texture(randomDoorTex) projectUV(0) # ---------------------------------------- # Ledges # ---------------------------------------- TopLedge --> WallStripe BottomLedge(floorindex) --> case floorindex == 1 : split(y){~1 : Wall(0) | ~1 : s('1,'1,0.2) LedgeAsset} case floorindex == 999 : split(y){~1 : WallStripe | ~1 : s('1,'1,0.2) LedgeAsset} else : WallStripe WallStripe --> split(x){ 0.5 : Wall(1) | ~1 : Wall(2) | 0.5 : Wall(1) } LedgeAsset --> i(ledge_asset) Wall(0) # ---------------------------------------- # Balcony # ---------------------------------------- Balcony --> s('1,2,1) t(0,-0.3,0) primitiveCube() split(y){0.2 : BalconyBeams | 0.3 : BalconyFloor | 1 : RailingBox } BalconyBeams --> split(x){ ~0.4 : s(0.2,'1,'0.9) center(x) Wall(0) }* RailingBox --> comp(f){front : Rail | left : Rail | right : Rail} // | left : Rail | right : Rail}} Rail --> s('1.1,'1,0.1) t(0,0,-0.1) center(x) primitiveCube() Wall(0) BalconyFloor --> Wall(0) # ---------------------------------------- # Wall # ---------------------------------------- getWalltype(floorindex) = case floorindex == 0 : 1 case floorindex == 1 : 1 else : 2 Wall(walltype) --> // dark bricks with dirt case walltype == 1 : color(wallColor) texture(wall_tex) set(material.dirtmap, dirt_tex) projectUV(0) projectUV(2) // bright bricks with dirt case walltype == 2 : color(wallColor) texture(wall2_tex) set(material.dirtmap, dirt_tex) projectUV(0) projectUV(2) // dirt only else : color(wallColor) set(material.dirtmap, dirt_tex) projectUV(2) SolidWall --> s('1,'1,wall_inset) t(0,0,-wall_inset) primitiveCube() Wall(1)