/** * File: Platform.cga * Created: 22 Nov 2017 14:17:45 GMT * Author: nsorsen2 */ version "2017.0" @Range(0,1,2,3,4) attr FIRST_Type = 4 attr height = 5 @Range(0.25,1) attr platform_height = 1 @Range(1.25,2) attr stair_width = 2 attr basemolding_platform_ratio = 0.82 attr building_platform_ratio = 0.8 attr door_height = 2 attr door_width = 1 attr roof_height = 2 attr roof_overhang = 0.25 attr roof_angle = 50 attr offset_distance = (roof_height)/(tan(roof_angle)) @Range ("Hip", "Flat") attr roof_type = "Hip" //Textures side_texture = "assets/Texture/ClayWall.jpg" side_texture2 = "assets/Texture/Bonampak_Red.jpg" top_texture = "assets/Texture/Floor.jpg" ground_texture = "assets/Texture/green_01.jpg" dirt_texture = "assets/Texture/dirt.jpg" wall_texture = "assets/Texture/ClayWall.jpg" wall_texture2 = "assets/Texture/Bonampak_Red.jpg" roof_texture = "assets/Texture/Thatch.jpg" //Create rectangular platform footprint @StartRule Lot--> innerRectangle(scope){shape:PlatformFootprint | remainder:Ground} //Texture space outside of platform footprint as ground Ground--> setupProjection(0, scope.xz, 10, 10) projectUV(0) texture(ground_texture) //Cut away front strip of platform to be used for staircase PlatformFootprint--> case FIRST_Type == 1: split(z){~1:Structure | 0.6:FrontStair} case FIRST_Type == 2: split(z){~1:Structure | 0.6:FrontStair} case FIRST_Type == 3: split(z){~1:Structure | 0.75:FrontStair} case FIRST_Type == 4: split(z){~1:Structure | 0.9:FrontStair} else: Structure //Split front strip into staircase and greenspace FrontStair--> split(x){~1:Ground | stair_width:Steps | ~1:Ground} //Split staircase into appropriate number of steps for each building type/height Steps--> case FIRST_Type == 1: split(z){~1:Step1} case FIRST_Type == 2: split(z){~1:Step3 | ~1:Step2 | ~1:Step1} case FIRST_Type == 3: split(z){~1:Step4 | ~1:Step3 | ~1:Step2 | ~1:Step1} case FIRST_Type == 4: split(z){~1:Step5 | ~1:Step4 | ~1:Step3 | ~1:Step2 | ~1:Step1} else: extrude(0) //Extrude steps to appropriate height for each building type Step1--> case FIRST_Type == 1: extrude(0.05) comp(f){side: DirtPadSide | top: DirtPadTop} else: extrude(0.2) comp(f){side: PlatformSide | top: PlatformTop} Step2--> extrude(0.4) comp(f){side: PlatformSide | top: PlatformTop} Step3--> case FIRST_Type == 2: extrude(0.5) comp(f){side: PlatformSide | top: PlatformTop} else: extrude(0.6) comp(f){side: PlatformSide | top: PlatformTop} Step4--> case FIRST_Type == 3: extrude(0.75) comp(f){side: PlatformSide | top: PlatformTop} else: extrude(0.8) comp(f){side: PlatformSide | top: PlatformTop} Step5--> case FIRST_Type == 4: extrude(platform_height) comp(f){side: PlatformSide | top: PlatformTop} else: extrude(1) comp(f){side: PlatformSide | top: PlatformTop} //Extrude structure to max height, split into platform and building Structure--> case FIRST_Type == 1: extrude(2.2) split(y){0.05:DirtPad | ~1:Building} case FIRST_Type == 2: extrude(2.9) split(y){0.5:Platform | ~1:Building} case FIRST_Type == 3: extrude(3.05) split(y){0.75:Platform | 0.15:BaseMolding | ~1:Building} case FIRST_Type == 4: extrude(height) split(y){1:Platform | 0.15:BaseMolding | ~1:Building} else: extrude(height) //Break platform into components Platform--> comp(f){side: PlatformSide | top: PlatformTop} DirtPad--> comp(f){side: DirtPadSide | top: DirtPadTop} //Texture platform sides PlatformSide--> case FIRST_Type == 4: setupProjection(0, scope.xy, 0.5, 0.5) projectUV(0) texture(side_texture2) else: setupProjection(0, scope.xy, 0.5, 0.5) projectUV(0) texture(side_texture) DirtPadSide--> setupProjection(0, scope.xy, 1, 1) projectUV(0) texture(dirt_texture) //Texture platform top PlatformTop--> setupProjection(0, scope.xy, 10, 10) projectUV(0) texture(top_texture) DirtPadTop--> setupProjection(0, scope.xy, 1, 1) projectUV(0) texture(dirt_texture) ################################################################### //Set scope for base molding, break into components BaseMolding--> case FIRST_Type == 3: s('basemolding_platform_ratio,'1,'basemolding_platform_ratio) center(xyz) comp(f){front:BaseMoldFront | side:BaseMoldSide | top:Floor} case FIRST_Type == 4: s('basemolding_platform_ratio,'1,'basemolding_platform_ratio) center(xyz) comp(f){front:BaseMoldFront | side:BaseMoldSide | top:Floor} else: Building //Texture base molding sides BaseMoldFront--> case FIRST_Type == 4: setupProjection(0, scope.xy, 0.5, 0.5) projectUV(0) texture(side_texture2) case FIRST_Type == 3: setupProjection(0, scope.xy, 0.5, 0.5) projectUV(0) texture(side_texture2) else: setupProjection(0, scope.xy, 0.5, 0.5) projectUV(0) texture(side_texture) BaseMoldSide--> case FIRST_Type == 4: setupProjection(0, scope.xy, 0.5, 0.5) projectUV(0) texture(side_texture2) case FIRST_Type == 3: setupProjection(0, scope.xy, 0.5, 0.5) projectUV(0) texture(side_texture2) else: setupProjection(0, scope.xy, 0.5, 0.5) projectUV(0) texture(side_texture) //Texture base molding top Floor--> setupProjection(0, scope.xy, 10, 10) projectUV(0) texture(top_texture) ############################################################################### //Set scope for building, break into components Building--> s('building_platform_ratio,'1,'building_platform_ratio) center(xyz) comp(f){front:Front | back:Facade | side:Side | top: Roof} //Build front wall with entrance Front--> split(x) {~1:Facade | door_width : DoorSplitY | ~1:Facade} DoorSplitY--> case FIRST_Type == 4: split(y) {door_height:Door | 0.15:FrontMedialMolding | ~1:Facade | 0.15:FrontCorniceMolding} else: split(y) {door_height:Door | ~1:Facade} Facade--> case FIRST_Type == 4: split(y){door_height:Wall | 0.15:FrontMedialMolding | ~1:Wall | 0.15:FrontCorniceMolding} else: Wall //Build side walls Side--> case FIRST_Type == 4: split(y){door_height:Wall | 0.15:SideMedialMolding | ~1:Wall | 0.15:SideCorniceMolding} else: Wall //Texture walls Wall--> case FIRST_Type == 4: setupProjection(0, scope.xy, 5, 5) projectUV(0) texture(wall_texture2) case FIRST_Type == 3: setupProjection(0, scope.xy, 5, 5) projectUV(0) texture(wall_texture2) else: setupProjection(0, scope.xy, 5, 5) projectUV(0) texture(wall_texture) //Texture door Door--> color(0,0,0) //setupProjection(0, scope.xy, 0.1, 0.1) //projectUV(0) //texture(door_texture) ########################################################################################### //Build roof Roof--> case FIRST_Type == 4: FlatRoof else: roofHip(50, 0.25) comp(f){front:Thatch | back:Thatch | left:Thatch2 | right:Thatch2} // case FIRST_Type == 4: // setupProjection(0, scope.xz, 10, 10) // projectUV(0) // texture(top_texture) // else: // s(scope.sx+roof_overhang,scope.sy+roof_overhang,'1) // center(xyz) // offset(-offset_distance) // comp(f){inside:RoofTop | border:RoofSides} //RoofTop--> // t(0,0,roof_height) //RoofSides--> // case comp.index == 0: // RoofSide1 // case comp.index == 1: // RoofSide2 // case comp.index == 2: // RoofSide3 // case comp.index == 3: // RoofSide4 // else: // NIL //RoofSide1--> // roofShed(roof_angle,4) // Thatch //RoofSide2--> // roofShed(roof_angle,4) // Thatch //RoofSide3--> // roofShed(roof_angle,4) // Thatch //RoofSide4--> // roofShed(roof_angle,4) // Thatch //Texture flat (Type 4) roof FlatRoof--> setupProjection(0, scope.xy, 2, 2) projectUV(0) texture(top_texture) //Texture thatch roofs Thatch--> setupProjection(0, scope.xy, 2, 2) projectUV(0) texture(roof_texture) Thatch2--> setupProjection(0, scope.xy, 2, 2) projectUV(0) texture(roof_texture) ########################################################################## //Build medial molding FrontMedialMolding--> extrude(face.normal, 0.1) comp(f){top:MedMoldFront | world.up:MedMoldTop | world.down:MedMoldBottom} SideMedialMolding--> extrude(face.normal, 0.1) comp(f){top:MedMoldFront | world.up:MedMoldTop | world.down:MedMoldBottom | side:MedMoldExtension} //Texture medial molding MedMoldFront--> setupProjection(0, scope.xy, 0.1, 0.1) projectUV(0) texture(side_texture2) MedMoldSide--> setupProjection(0, scope.xy, 0.1, 0.1) projectUV(0) texture(side_texture2) MedMoldBottom--> setupProjection(0, scope.xz, 0.1, 0.1) projectUV(0) texture(side_texture2) MedMoldTop--> setupProjection(0, scope.xz, 0.1, 0.1) projectUV(0) texture(side_texture2) MedMoldExtension--> extrude(face.normal,0.1) comp(f){top:MedMoldFront | back:MedMoldFront | world.up:MedMoldTop | world.down:MedMoldBottom} ########################################################################################### //Build cornice Molding FrontCorniceMolding--> extrude(face.normal, 0.1) comp(f){top:CornMoldFront | world.up:CornMoldTop | world.down:CornMoldBottom} SideCorniceMolding--> extrude(face.normal, 0.1) comp(f){top:CornMoldFront | world.up:CornMoldTop | world.down:CornMoldBottom | side:CornMoldExtension} //Texture cornice molding CornMoldFront--> setupProjection(0, scope.xy, 0.1, 0.1) projectUV(0) texture(side_texture2) CornMoldSide--> setupProjection(0, scope.xy, 0.1, 0.1) projectUV(0) texture(side_texture2) CornMoldBottom--> setupProjection(0, scope.xz, 0.1, 0.1) projectUV(0) texture(side_texture2) CornMoldTop--> setupProjection(0, scope.xz, 0.1, 0.1) projectUV(0) texture(side_texture2) CornMoldExtension--> extrude(face.normal,0.1) comp(f){top:CornMoldFront | back:CornMoldFront | world.up:CornMoldTop | world.down:CornMoldBottom}