// Source: peyep 官方 demo 回填(原始 cityengine 规则)· https://www.peyep.com/#/demo/simplebuilding-textured-20260929 /** * Author: Esri R&D Center Zurich */ version "2023.0" /* Attributes *************************************/ attr groundfloor_height = 4 attr floor_height = 3.5 attr tile_width = 4 attr height = 11 // textures & colors const wall_tex = "facades/brick_white_02.jpg" const dirt_tex = "dirtmaps/dirtmap_04.jpg" const roof_tex = "roofs/flat_01.jpg" const window_color = "#85acd6" const frame_color = "#444444" const door_color = "#666666" /* Initial Shape starting rule ********************/ # extrude the lot to the 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.5, 0, 0, 1) # setup 1.5m x 1.5m 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.5, 0, 0, 1) # setup 1.5m x 1.5m 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}* } # a flat roof is created by offsetting the roof face from the wall # and then lowering it slightly Roof --> offset(-0.4, inside) t(0, 0, -0.2) setupProjection(0, scope.xy, scope.sx, scope.sy) texture(roof_tex) projectUV(0) # 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) { 0.5 : SolidWall | { ~tile_width : Tile }* | 0.5 : SolidWall } # similarly, 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) { 0.5 : SolidWall | { ~tile_width : Tile }* | ~tile_width : EntranceTile | 0.5 : SolidWall } # a tile consists of a centered window element # and wall elements around it Tile --> split(x) { 1 : SolidWall | ~1.5 : split(y) { 0.4 : SolidWall | ~1.5 : Window | 0.4 : SolidWall } | 1 : SolidWall } # similarly, the EntranceTile contains a centered Door element, # but with no spacing below EntranceTile --> split(x) { ~1 : SolidWall | 2.5 : split(y) { 3 : Door | ~2 : SolidWall } | ~1 : SolidWall } # a solid wall is created SolidWall --> s('1, '1, -0.4) primitiveCube() comp(f) { side : Wall | all : setupProjection(0, scope.xy, 1.5, 1.5, 0, '1) Wall } # texture the wall Wall --> texture(wall_tex) set(material.dirtmap, dirt_tex) projectUV(0) projectUV(2) # first the depth and the position of the future window is set # then the window is split into frame and glass parts Window --> t(0, 0, -0.2) split(y) { 0.1 : Frame | ~1 : split(x) { 0.1 : Frame | { ~1 : Glass | 0.1 : Frame }* } | 0.1 : Frame } # color the window and set properties for a glass material Glass --> color(window_color) set(material.specular.r, 0.5) set(material.specular.g, 0.5) set(material.specular.b, 0.5) set(material.reflectivity, 0.5) set(material.shininess, 50) set(material.opacity, 0.9) # color the window frame Frame --> color(frame_color) # the door is split similar to the windows but with different spacings # and no bottom frame Door --> t(0, 0, -0.4) split(y) { ~1 : split(x) { 0.15 : Frame | ~1 : Panel | 0.05 : Frame | ~1 : Panel | 0.15 : Frame } | 0.15 : Frame } # color the door Panel --> color(door_color)