Tutorial 9: Advanced shape grammar -...

13
Tutorial 9: Advanced shape grammar Copyright © 1995-2013 Esri. All rights reserved.

Transcript of Tutorial 9: Advanced shape grammar -...

Page 1: Tutorial 9: Advanced shape grammar - ArcGISresources.arcgis.com/.../10.2/tutorial_9_advanced_shape_grammar.pdf · Tutorial 9: Advanced shape grammar ... The railing will be placed

Tutorial 9: Advanced shapegrammar

Copyright © 1995-2013 Esri. All rights reserved.

Page 2: Tutorial 9: Advanced shape grammar - ArcGISresources.arcgis.com/.../10.2/tutorial_9_advanced_shape_grammar.pdf · Tutorial 9: Advanced shape grammar ... The railing will be placed

Table of ContentsTutorial 9: Advanced shape grammar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Tutorial 9: Advanced shape grammar

Copyright © 1995-2013 Esri. All rights reserved. 2

Page 3: Tutorial 9: Advanced shape grammar - ArcGISresources.arcgis.com/.../10.2/tutorial_9_advanced_shape_grammar.pdf · Tutorial 9: Advanced shape grammar ... The railing will be placed

Tutorial 9: Advanced shape grammarIn this tutorial:

• Part 1: Complex Facade Patterns

• Part 2: The Candler Building

• Part 3: The Parthenon Temple

Download:

• Tutorial Data

• Tutorial PDF

Part 1: Complex Facade Patterns

This tutorial shows how to model a building from a picture and introduces some more complex CGA techniques.

Tutorial Setup

Open scene ComplexPatterns.cej.

Generate the Building

This tutorial explains how to create a set of CGA rules to recreate a building from a real-world photograph with pure CGA. The facadewe're going to model can be seen on the picture below. Due to the tricky patterns of the tile and window layout in this example we willneed some more advanced CGA mechanisms like nested repeat splits and parameter passing.

Tutorial 9: Advanced shape grammar

Copyright © 1995-2013 Esri. All rights reserved. 3

Page 4: Tutorial 9: Advanced shape grammar - ArcGISresources.arcgis.com/.../10.2/tutorial_9_advanced_shape_grammar.pdf · Tutorial 9: Advanced shape grammar ... The railing will be placed

In case you want to generate the building beforehand:

Steps:

1. Select one of the lots in the 3D viewport.

2. Click the generate button from the top toolbar.

Facade Analysis

When planning a new CGA rule, it is helpful to shortly sketch the crude layout and define some of the shape names before starting towrite the rules.

The facade we want to model consists mainly of three floor types, Top, Ground and Upper Floors. The lower floors are made of tilescontaining windows, whereas the top floor only contains window elements. Every second of the lower floors is identical, so we'll haveto pass the index (the floorIndex) with the Floor shape to create the correct look (tile and window alignment) for a specific floor.

Due to the pattern of the tiles, we define an intermediate DoubleTile shape, which contains two Tile shapes and which will be helpfulonce we're encoding the floor patterns:

Tutorial 9: Advanced shape grammar

Copyright © 1995-2013 Esri. All rights reserved. 4

Page 5: Tutorial 9: Advanced shape grammar - ArcGISresources.arcgis.com/.../10.2/tutorial_9_advanced_shape_grammar.pdf · Tutorial 9: Advanced shape grammar ... The railing will be placed

Next, we define the detailed subshapes in a tile. It consists of two main parts. The MilkGlass and the Window shape, whereas thesecond again contains a Blind on the top and an embedded Subwindow shape. The position of these elements depend on thehorizontal position of the tile on the floor, so we need to store this position index (we will call it tileIndex) as a parameter of the Tileshape to be able to place the subshape structure correctly.

Steps:

1. Double-click the file complexpatterns_01.cga in the Navigator to open the CGA editor and to see the rules that createour facade.

2. Switch to CGA textual mode, in case the visual representation opens. The buttons are found in the toolbar of the CGAeditor.

Tutorial 9: Advanced shape grammar

Copyright © 1995-2013 Esri. All rights reserved. 5

Page 6: Tutorial 9: Advanced shape grammar - ArcGISresources.arcgis.com/.../10.2/tutorial_9_advanced_shape_grammar.pdf · Tutorial 9: Advanced shape grammar ... The railing will be placed

Attributes, Variables and Assets

Attributes are defined on the very beginning of the rule file. These attributes are used through the whole rule set and can also bemodified via the Windows > Inspector outside the CGA Grammar Editor

// User Attribute@Group("Building", 1) @Range(5,40)attr buildingH = 27 // building height@Group("Facade", 2) @Range(3,6)attr floorH = 3.5 // floor height@Group("Facade") @Range(3,6)attr groundfloorH = floorH + 1 // groundfloor height@Group("Facade") @Range(1,4)attr nSymmetries = 2@Group("Facade") @Range(0.1,1)attr borderwallW = 0.3 // width of border wall stripe@Group("Facade") @Range(0.1,0.8)attr ledgeH = 0.3 // ledge height@Group("Window",3) @Range(1,5)attr windowW = 2.5 // window width@Group("Window") @Range(1,5)attr milkGlassW = windowW/2 // milkglass blend width@Group("Window") @Range(0.1,2.5)attr blindH = 0.8 // blind height@Group("Window") @Range(0.01,0.5)attr frameW = 0.07 // frame width@Group("Balcony",4) @Range(3,6)attr balconyDepth = 2@Group("Colors",5)attr brightblue = "#86b1c7"@Group("Colors",5)attr darkblue= "#33556c"@Group("Colors",5)attr red = "#5c3f40"@Group("Colors",5)attr grey ="#6b7785"@Group("Colors",5)attr white = "#ffffff"

Annotations such as @Group or @Range are added to attributes to control their appearance in the Inspector.

Other variables and assets are defined in the following block:

tileW = windowW + milkGlassW // total tile widthconst barDiameter = 0.04// assetsconst cyl_v = "general/primitives/cylinder.vert.8.notop.tex.obj"const cyl_h = "general/primitives/cylinder.hor.8.notop.tex.obj"const window_tex = "facade/windows/1_glass_2_blue.tif"const milkGlass_tex = "facade/windows/blend_tex.png"

Tutorial 9: Advanced shape grammar

Copyright © 1995-2013 Esri. All rights reserved. 6

Page 7: Tutorial 9: Advanced shape grammar - ArcGISresources.arcgis.com/.../10.2/tutorial_9_advanced_shape_grammar.pdf · Tutorial 9: Advanced shape grammar ... The railing will be placed

The actual creation of the building starts now. First, the mass model is created with the extrude operation. The top floor is split fromthe main part and split again to create the set-back balcony.

Lot -->extrude(buildingH) // extrude the buildingsplit(y){ ~1: MainPart | floorH: UpperPart } // split top floor from lower floors

UpperPart -->split(z){ ~1: TopFloor | balconyDepth: Balcony } // create a set-back by splitting in the direction of the building depth

Component splits are applied then to the different volume parts to distinguish the front, side and top faces and to trigger facade, walland roof rules.

MainPart -->comp(f){ front: Facade | side: Wall | top: Roof } // create a facade on the front face, walls on the side faces, and a roof on the top face

TopFloor -->comp(f){ front: Floor(-1) | side: Wall | top: Roof } // create a floor (marked with -1 as top floor) on the front face, walls on the side and roof on the top face

The dimensions of the balcony are set. The railing will be placed on the faces of the current shape, so we use a component split toget the front, left and right faces for the Railing rule.

Balcony -->s(scope.sx-2*borderwallW,0.7,scope.sz-borderwallW) center(x) // set balcony height to 0.7 meters (railing height)comp(f){ front: Railing | left: Railing | right: Railing }

The crude building shape after volume modeling:

Facade and Floors

We now subdivide the front facade further. The first split subdivides the facade into a ground floor part and a set of upper floors withthe help of a repeating split {...}*. The tilde sign ~ before the split size (e.g. ~groundfloorH) allows a flexible height and ensuresmatching floors with now holes in the facade. By passing the split index split.index (which represents the floor index) as a parameter,we can later trigger specific floor features.

Facade -->// split the Facade into a groundfloor and repeated upper floors

// (all floors are marked with their split index, which represents the floor number)split(y){ ~groundfloorH: Floor(split.index) | { ~floorH: Floor(split.index) }* }

Every floor has a narrow Wall area on its left and right borders. We create this with a simple split in x-direction.

Tutorial 9: Advanced shape grammar

Copyright © 1995-2013 Esri. All rights reserved. 7

Page 8: Tutorial 9: Advanced shape grammar - ArcGISresources.arcgis.com/.../10.2/tutorial_9_advanced_shape_grammar.pdf · Tutorial 9: Advanced shape grammar ... The railing will be placed

Floor(floorIndex) -->// create a narrow wall element on both sides of every floor.//the floorIndex parameter is passed on to be used latersplit(x){borderwallW: Wall | ~1: FloorSub(floorIndex) | borderwallW: Wall }

Depending on the floor index, special horizontal elements are now created for every floor with horizontal split commands:

1. The upper floors only feature a top ledge.

2. The top floor has no additional elements and triggers the TileRow shape directly.

3. We'll be using the floor index again in a later rule, so we pass it again as a parameter with the TileRow shape.

FloorSub(floorIndex) -->case floorIndex == 0: // ground floor with index 0.

split(y){ 1: Wall | ~1: TileRow(floorIndex) | ledgeH: Wall}case floorIndex > 0: // upper floors

split(y){ ~1: TileRow(floorIndex) | ledgeH: Ledge }else: // topfloor with index -1.

TileRow(floorIndex)

Facade with floor and ledge splits:

Tiles

We're now going to split the floors into tiles. For the top floor things are easy: there is now special pattern, just repeating windowelements. To address these tiles later on, we again mark them with the parameter -1.

To create the special repeating pattern for the main floors, we create an intermediate shape called DoubleTile. To align the windowelements correctly in a later step, we need the floor and the tile index (split.index), which we pass as parameters.

TileRow(floorIndex) -->case floorIndex == -1:

split(x){ ~windowW: Tile(-1) }*// Repeating shape Tiles on the top floor, marked again with -1

else:split(x){ ~tileW*nSymmetries: DoubleTile(floorIndex,split.index) }*

// the floor is subdivided into regular DoubleTile shapes, the floor index is passed as parameter

The combination of floor and tile index determines the alignment of the windows. We therefore have two rules with repeating splitswith different order of the MilkGlass and the Tile shape.

Tutorial 9: Advanced shape grammar

Copyright © 1995-2013 Esri. All rights reserved. 8

Page 9: Tutorial 9: Advanced shape grammar - ArcGISresources.arcgis.com/.../10.2/tutorial_9_advanced_shape_grammar.pdf · Tutorial 9: Advanced shape grammar ... The railing will be placed

DoubleTile(floorIndex,tileIndex) -->case tileIndex%2 + floorIndex%2 == 1:

// windows are right-alignedsplit(x){ ~milkGlassW: MilkGlass | ~windowW: Tile(tileIndex) }*

else:// windows are left-aligned

split(x){ ~windowW: Tile(tileIndex) | ~milkGlassW: MilkGlass }*

We first setup the texture coordinates for the future window texture. The whole Tile shape is then split horizontally into window framesand the center part. The center part is again split, this time vertically into Frame, Window, Blind and Bracing.

Tile(tileIndex) -->setupProjection(0,scope.xy,scope.sx,scope.sy)

// setup the texture coordinates for the windowssplit(x){ frameW: Frame Bracing

// this triggers the window frame as well as the bracing on the left side of the window// the center window is split into Frame, Window, Frame, Blind

// and Frame from bottom to top| split(y){ frameW: Frame

| ~1: Window(tileIndex)| frameW: Frame| blindH: Blind| frameW: Frame }| frameW: Frame Bracing }// frame and bracing on the window's right side

Windows

For the Window shape, the tile index of the DoubleTile is used to determine the position of the subwindows.

Window (tileIndex) -->

Whereas here left-aligned subwindows in the right half of the window are placed.

case tileIndex%nSymmetries >= 0:split(x){ ~1: Glass | frameW: Frame | ~1: Subwindow("left") }

The tile index -1 representing the top floor windows is now used to create windows with no subwindows.

else:split(x){ ~1: Glass | frameW: Frame | ~1: Glass}}

With the help of the parameters "left" or "right", the RedWindow is placed on the correct spot.

Tutorial 9: Advanced shape grammar

Copyright © 1995-2013 Esri. All rights reserved. 9

Page 10: Tutorial 9: Advanced shape grammar - ArcGISresources.arcgis.com/.../10.2/tutorial_9_advanced_shape_grammar.pdf · Tutorial 9: Advanced shape grammar ... The railing will be placed

Subwindow(align) -->case align == "left":

split(x){~3: RedWindow | ~2: Glass} // put the RedWindow to the leftelse:

split(x){~2: Glass | ~3: RedWindow } // and to the right otherwise

The following rule creates the frame and glass elements for the RedWindow shape.

RedWindow -->split(x){ frameW: RedFrame // left...

| ~1: split(y){ frameW: RedFrame| ~1:RedGlass | frameW: RedFrame } // ... bottom, top ...

| frameW: RedFrame } // ... and right frameRedGlass -->

split(y){ ~1: Glass | frameW/2: t(0,0,-frameW) Frame | ~1: t(0,0,-frameW) Glass }

Detailed window geometry:

Materials

Wall --> color(darkblue)Blind --> color(grey)Frame -->

extrude(frameW) color(white) // extrude the frame to the frontRedFrame -->

t(0,0,-frameW) extrude(frameW*4) color(red)Glass -->

projectUV(0) // apply texture coordinates to current shape geometrytexture(window_tex) color(white) // and assign texture and colorset(material.specular.r, 0.4)

set(material.specular.g, 0.4)set(material.specular.b, 0.4)

set(material.shininess, 4)set(material.reflectivity,0.3)

MilkGlass -->s('1,'1,frameW*1.2) i("builtin:cube")color(brightblue)setupProjection(0, scope.xy, scope.sx,scope.sy, 0)

texture(milkGlass_tex)projectUV(0)

set(material.specular.r, 0.7)set(material.specular.g, 0.7)set(material.specular.b, 0.7)

set(material.shininess, 20)set(material.reflectivity,0.05)

Colored and textured model after applying material rules:

Tutorial 9: Advanced shape grammar

Copyright © 1995-2013 Esri. All rights reserved. 10

Page 11: Tutorial 9: Advanced shape grammar - ArcGISresources.arcgis.com/.../10.2/tutorial_9_advanced_shape_grammar.pdf · Tutorial 9: Advanced shape grammar ... The railing will be placed

Detail Elements

We refine the floor ledges by adding a back wall element, a cube to give it some depth, and a second thin cube that serves as a coverplate.

Ledge -->Wall[ s('1,'0.9,0.2) i("builtin:cube") Wall ]t(0,-0.1,0.2) s('1,scope.sy+0.1,0.03) i("builtin:cube") Wall

A horizontal bar is first inserted to create the horizontal part of the railing. By disabling vertical trimming the following vertical cornerbars are prevented from being cut.

The vertical bars are evenly distributed with the help of a repeat split with a floating split width.

Railing -->[ t(0,scope.sy-barDiameter/2,0) HBar ]set(trim.vertical, false)split(x){ ~tileW/3: VBar }*

Cylinder assets are inserted to create the vertical and horizontal bars.

VBar --> s(barDiameter,'1,barDiameter) t(0,0,-barDiameter) i(cyl_v) color(white)HBar --> s('1,barDiameter,barDiameter) t(0,0,-barDiameter) i(cyl_h) color(white)

The bracing of the windows consist of top and bottom mountings, and a vertical bar in the middle. For the mountings a cube isinserted, the VBar again triggers the cylinder asset.

Bracing -->s(barDiameter,'1,0.15) center(x) i("builtin:cube")

split(y){ 0.01: Wall | ~1: t(0,0,0.15) VBar | 0.01: Wall }

Final model with detail elements such as ledges, window bracings and railings added:

Tutorial 9: Advanced shape grammar

Copyright © 1995-2013 Esri. All rights reserved. 11

Page 12: Tutorial 9: Advanced shape grammar - ArcGISresources.arcgis.com/.../10.2/tutorial_9_advanced_shape_grammar.pdf · Tutorial 9: Advanced shape grammar ... The railing will be placed

Now you have the final model, try to apply the rule on different lot shapes, or play around with the user attributes found in theinspector to modify your facade design.

A Different Style

Using the style keyword, a new style is defined that redefines some attributes. In this case, we simply create a color variation byredefining the color attributes.

@Description("A Variation in Red")style Red_Color_Themeattr brightblue = "#FF8080"attr darkblue = "#D20000"attr grey = "#ECCACA"attr red = "#361B1B"

The Red_Color_Theme style applied:

Tutorial 9: Advanced shape grammar

Copyright © 1995-2013 Esri. All rights reserved. 12

Page 13: Tutorial 9: Advanced shape grammar - ArcGISresources.arcgis.com/.../10.2/tutorial_9_advanced_shape_grammar.pdf · Tutorial 9: Advanced shape grammar ... The railing will be placed

Part 2: The Candler Building

Steps:

1. Open scene Candler_Building.cej.

2. Select the lot in the 3D viewport.

3. Click the Generate button in the toolbar.

4. Double-click the file candler.01.cga in the Navigator to see the rules that create the Candler Building.

Part 3: The Parthenon Temple

Steps:

1. Open scene Parthenon.cej.

2. Select the lot in the 3D viewport.

3. Click the Generate button from the top toolbar.

4. Double-click the file parthenon.cga in the Navigator to see the rules that create the Parthenon Temple.

Tutorial 9: Advanced shape grammar

Copyright © 1995-2013 Esri. All rights reserved. 13