/** * File: Stairs.cga * Created: 1 May 2018 22:55:33 GMT * Author: hrichards-rissetto2 */ version "2017.0" #import base: "Base.cga" @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 FrontStair--> setupProjection(0, scope.xz, 10, 10) projectUV(0) texture(ground_texture) //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) Building--> setupProjection(0, scope.xy, 10, 10) projectUV(0) texture(top_texture) BaseMolding--> Platform //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) //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} //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) //Texture space outside of platform footprint as ground Ground--> setupProjection(0, scope.xz, 10, 10) projectUV(0) texture(ground_texture)