tutorial 3: map control -...

13
Tutorial 3: Map control Copyright © 1995-2013 Esri. All rights reserved.

Upload: others

Post on 31-May-2020

22 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Tutorial 3: Map control - ArcGISresources.arcgis.com/.../pdf/cityengine/10.2/tutorial_3_map_control.p… · Tutorial 3: Map control In this tutorial: • Part 1: Understanding CGA

Tutorial 3: Map control

Copyright © 1995-2013 Esri. All rights reserved.

Page 2: Tutorial 3: Map control - ArcGISresources.arcgis.com/.../pdf/cityengine/10.2/tutorial_3_map_control.p… · Tutorial 3: Map control In this tutorial: • Part 1: Understanding CGA

Table of ContentsTutorial 3: Map control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Tutorial 3: Map control

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

Page 3: Tutorial 3: Map control - ArcGISresources.arcgis.com/.../pdf/cityengine/10.2/tutorial_3_map_control.p… · Tutorial 3: Map control In this tutorial: • Part 1: Understanding CGA

Tutorial 3: Map controlIn this tutorial:

• Part 1: Understanding CGA parameters

• Part 2: Controlling the Skyline

• Part 3: Controlling Land-Use Types

Download:

• Tutorial Data

• Tutorial PDF

Part 1: Understanding CGA parameters

Cities consist of a large number of objects. Controlling these by setting attributes of the single buildings is tedious or impossible. Inthis tutorial you will learn first how CGA rule parameters are used.

Steps:

1. Open the scene mapcontrolTutorial_01.cej.

What's in there already?

The opened scene contains 2 map layers (Terrain and Water) and a street network layer with lot shapes.

Where do Rule Parameters come from?

If you select a single lot now and check its attributes in the Inspector (Window > Inspector), there are no rule parameters assigned(the Rule Parameter pane is empty). This will change as soon as we assign a rule file to the lot.

Steps:

1. Select the Streetnetwork layer in the Scene Editor.

2. Click Shapes > Assign Rule File and select the Rule File simpleBuildingShells_01.cga.

3. Select a single lot again.Now there are attributes visible in the Inspector view, namely height.

Where did they come from? As soon as you assign a rule file to a shape (in our case a lot), the attributes of the rule fileare visible as rule parameters of the lot. The entry Rule in the Source column shows that the value is taken from the rulefile.

4. Click on the Rule File link in the Inspector to open the assigned rule file.

5. Change the Rule Editor’s view to the textual representation.

6. On the very top the attribute height is defined:

Tutorial 3: Map control

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

Page 4: Tutorial 3: Map control - ArcGISresources.arcgis.com/.../pdf/cityengine/10.2/tutorial_3_map_control.p… · Tutorial 3: Map control In this tutorial: • Part 1: Understanding CGA

This value is used in the rule file to define the ‘height’ of the building.

// height valueattr height = 80

7. Now reselect the lot and generate the building.

You’ll get a building which is 80 meters high.

8. Change the height value in the Inspector from 80 to 150.

Note how the entry Rule disappeared. The rule parameter height for this building is now overruled by the value set by theuser. All other untouched lots still use the height value from the rule file.

9. Regenerate the building and note how the building height has changed.

At the end of Part 1 of this tutorial, your scene should look similar to this:

Alternatively, you can also open scene mapcontrolTutorial_02.cej to see the result of this tutorial's first part.

Part 2: Controlling the Skyline

As the second step, you'll learn how to use maps to control parameters of your cities.

Continue from part 1 or open scene mapcontrolTutorial_02.cej.

The Skyline Map

If you generate some buildings with the current settings, your city would look similar to this:

Tutorial 3: Map control

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

Page 5: Tutorial 3: Map control - ArcGISresources.arcgis.com/.../pdf/cityengine/10.2/tutorial_3_map_control.p… · Tutorial 3: Map control In this tutorial: • Part 1: Understanding CGA

This is not very convincing since all buildings are equally high, 80 meters. A nice skyline would improve the look. Instead of setting theCGA shape attributes by hand like in part 1, we're now going to use the red skyline map below, to control the height of all buildings atonce. The smaller image is the topography map which indicates a lake in blue.

Tutorial 3: Map control

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

Page 6: Tutorial 3: Map control - ArcGISresources.arcgis.com/.../pdf/cityengine/10.2/tutorial_3_map_control.p… · Tutorial 3: Map control In this tutorial: • Part 1: Understanding CGA

The red channel of the skyline map represents the height of the buildings in this area. Comparing the skyline map to the topographymap, you notice that we want to create a skyline that forms around the corner of the lake. There is also a second center in the city onthe top left.

Steps:

1. Create a new Map Layer : Layer > New Map Layer > Mapping

2. Choose the skylineMap.png as the Mapping file.

3. Switch off the Keep ratio button.

4. Change the X and Z Sizes to 3000.

5. Make sure the alignment is set to centered (clicking the alignment icon changes the mode).

6. Right-click into the Mappings area and Add Row…

7. Name the attribute skylineValue.

8. We want the red channel of the image to be interpreted as height, so select red from the channel dropdown.

Building heights should vary between 20 (0% red) and 200 (100% red) meters.

9. Enter therefore 20 for the Minimum and 200 for the Maximum value.

10. Click Finish and rename the created layer to Skyline Map in the Inspector.

Tutorial 3: Map control

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

Page 7: Tutorial 3: Map control - ArcGISresources.arcgis.com/.../pdf/cityengine/10.2/tutorial_3_map_control.p… · Tutorial 3: Map control In this tutorial: • Part 1: Understanding CGA

11. Adjust the elevation offset of your new map layer in the Inspector to bring it to a position with better visibility. Use thealpha value to give it some transparency.

Now, we can control the rule parameter height with our skyline map.

12. Reassign the rule file to your lots to tell the CityEngine to do the connection.

13. Select all lots.

14. Click on the connection icon for rule attribute height in the Inspector.This will open the Connection Editor.

15. Choose Layer attribute, select the new Skyline Map layer and the attribute skylineValue.

After setting the source to the skyline layer, the value shows a ? sign. This means that the selection contains differentvalues (all lots shapes have different height values).

16. Select a single lot and have another look at its attributes in the Inspector view. The value of height is now connected tothe Skyline Map.

Tutorial 3: Map control

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

Page 8: Tutorial 3: Map control - ArcGISresources.arcgis.com/.../pdf/cityengine/10.2/tutorial_3_map_control.p… · Tutorial 3: Map control In this tutorial: • Part 1: Understanding CGA

17. Now select some lots around the bay area and generate the buildings.

This is starting to look good, but we will improve it, using some more advanced CGA techniques.

Have a look at the rule file simpleBuildingShells_02.cga. Look for the following function:Height calculation with variation

// calc height with variationgetHeight(area) =

case area > 600 : rand(0,40)+heightcase area > 200 : rand(0,40)+height/2else: rand(15,30)

Instead of mapping the height value from the skyline map directly to the building height, the above user-defined functionis used. (See the CGA Shape Grammar Tutorial for details about CGA rules and functions). This function does thefollowing two things:

• High buildings will be created on big-area lots only.

• A random value is added to the incoming map value, to give the skyline some variation.

a. Select the lot layer in the Scene Editor.

b. Assign the ‘simpleBuildingShells_02.cga’ rule by right-clicking on the layer > Assign Rule File.

At the end of part 2 of this tutorial, your scene should look similar to this.

Tutorial 3: Map control

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

Page 9: Tutorial 3: Map control - ArcGISresources.arcgis.com/.../pdf/cityengine/10.2/tutorial_3_map_control.p… · Tutorial 3: Map control In this tutorial: • Part 1: Understanding CGA

Part 3: Controlling Land-Use Types

As the third step, you'll learn how to use maps to control the Land-Use Type of each building.

Continue from part 2 or open scene mapcontrolTutorial_03.cej.

Controlling Land-Use Types for Buildings

A city often has areas of specific land-use types. This part describes how to set the attributes for three different land-use types. Themap below marks commercial areas in blue, industrial areas in red and residential areas in green.

Tutorial 3: Map control

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

Page 10: Tutorial 3: Map control - ArcGISresources.arcgis.com/.../pdf/cityengine/10.2/tutorial_3_map_control.p… · Tutorial 3: Map control In this tutorial: • Part 1: Understanding CGA

Create the Land-Use Map Layer

Before creating the map layer, have a look at the rule file simpleBuildingShells_03.cga. Look for the 3 CGA attributes:CGA land use types attributes

// land use typesattr t_industrial = 0attr t_commercial = 0attr t_residential = 0

The map layer we are going to create needs to have attributes with matching names.

Steps:

1. Hide the Skyline Layer by clicking on the eye symbol in the Scene Editor.

2. Create a new Map Layer : Layer > New Map Layer > Mapping

3. Choose the areatypes.png as the Mapping file.

4. Switch off the Keep ratio button.

5. Change the X and Z Sizes to 3000.

6. Make sure the alignment is set to centered (clicking the alignment icon changes the mode).

7. Right-click into the Mappings area and Add Row.

8. Add 3 mapping attributes:• t_industrial > red channel

• t_commercial > green channel

• t_residential > blue channel

We will evaluate these parameters in the rule file again, therefore the default Minimum and Maximum values 0 and 1 area good generic mapping for future use.

9. Click Finish to create the map layer.

10. Rename the layer to LandUse Map in the Inspector.

Tutorial 3: Map control

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

Page 11: Tutorial 3: Map control - ArcGISresources.arcgis.com/.../pdf/cityengine/10.2/tutorial_3_map_control.p… · Tutorial 3: Map control In this tutorial: • Part 1: Understanding CGA

Adjust the display offset of your new map layer in the Inspector view to bring it to a position with better visibility. Use thealpha value to give it some transparency.

11. Select the new map layer and check its attributes in the Inspector.

Check that the three CGA attributes have correct mappings. If you want to change some of the settings of the map layerlater, use the Inspector.

Now the values of the Land-use map are going to be evaluated:

12. Select all lots.

13. Assign the rule file simpleBuildingShells_03.cga.

14. Set the source of the landuse parameters to the layer LandUse Map.

Tutorial 3: Map control

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

Page 12: Tutorial 3: Map control - ArcGISresources.arcgis.com/.../pdf/cityengine/10.2/tutorial_3_map_control.p… · Tutorial 3: Map control In this tutorial: • Part 1: Understanding CGA

Before we do the final building generation, have another look in the rule file ‘simpleBuildingShells_03.cga’ and locate thecolor declarations and the functionlanduseTypeColor:Color type for landuse

// color declarationsred = "#ffaaaa"green = "#aaffaa"blue = "#aaaaff"white = "#ffffff"

Color type for landuse

// FunctionslanduseTypeColor =

case t_industrial > t_commercial && t_industrial > t_residential : redcase t_commercial > t_industrial && t_commercial > t_residential : bluecase t_residential > t_industrial && t_residential > t_commercial : greenelse : white

This function analyses the values coming from the land-use map and returns a color accordingly. If the color channelvalue coming from the map is greater than the value of the other channels, the corresponding land-use color is returned,red for industrial, blue for commercial and green for residential buildings. By using the color operationcolor(landuseTypeColor) that is calling the land-use color function, the color is applied to the generated buildings.

15. Now generate all buildings in the scene.

16. Alternatively, you can also open scene mapcontrolTutorial_04.cej and generate the buildings to see the end result ofthis tutorial.

Tutorial 3: Map control

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

Page 13: Tutorial 3: Map control - ArcGISresources.arcgis.com/.../pdf/cityengine/10.2/tutorial_3_map_control.p… · Tutorial 3: Map control In this tutorial: • Part 1: Understanding CGA

Tutorial 3: Map control

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