Tutorial 7-Facade modeling

703
1
01-01-2014 04:14 PM
Divya_UdayanJ
New Contributor
In Tutorial 7-Facade modeling, it is shown that the picture has ground floor with only doors. But what if the ground floor has both windows and doors. How to write the CGA script? Please help me.
Also see the attached file for the 'code' and facade picture.

@StartRule
Lot --> s(15,15,15) extrude(height) Building



# we only need the front face for this example
Building --> comp(f) { front : Frontfacade | side : Frontfacade}



# the front facade is subdivided into one front groundfloor
# and upper floors
Frontfacade -->
split(y){ groundfloor_height : Floor(split.index) // Groundfloor
| floor_height : Floor(split.index) // First Floor
| floor_height : Floor(split.index) // Second Floor
| floor_height : Floor(split.index) // Third Floor
| floor_height : Floor(split.index) // Mid Floors
| floor_height : Floor(999) } // Top Floor, indexed with 999

Floor(floorindex)-->

case floorindex == 0:
Subfloor(floorindex)
case floorindex == 1:
split(y) {~1 : Subfloor(floorindex) Balcony | 0.5: TopLedge}
case floorindex == 4:
split(y) {~1 : Subfloor(floorindex) Balcony}
else:
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)}


Tile(floorindex)-->
case floorindex == 0 :

split(x){~1: SolidWall | door_width : DoorTile | ~1: SolidWall}
else:
split(x){~1: Wall(getWalltype(floorindex)) | window_width : WindowTile(floorindex) | ~1 : Wall(getWalltype(floorindex))}
0 Kudos
1 Reply
MatthiasBuehler1
Frequent Contributor II
Well, the theory is very simple to this problem:

Once you have split all floors, you split off the door on the first floor. then, the 'rest' shapes or that split plus all upper floor facades all are forwarded to the same rule that creates the windows ..

Maybe it's a good practice to code this from scratch instead of trying to understand existing code.. That can sometimes be a bit tedious.

Does that help a bit so far ?

matt
0 Kudos