tutorial 5: import initial shapes - arcgisresources.arcgis.com/en/help/pdf/cityengine/10.2/... ·...

12
Tutorial 5: Import initial shapes Copyright © 1995-2013 Esri. All rights reserved.

Upload: others

Post on 10-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Tutorial 5: Import initial shapes - ArcGISresources.arcgis.com/en/help/pdf/cityengine/10.2/... · 2013-12-05 · Shapes versus static models OBJ and Collada DAE files can be imported

Tutorial 5: Import initialshapes

Copyright © 1995-2013 Esri. All rights reserved.

Page 2: Tutorial 5: Import initial shapes - ArcGISresources.arcgis.com/en/help/pdf/cityengine/10.2/... · 2013-12-05 · Shapes versus static models OBJ and Collada DAE files can be imported

Table of ContentsTutorial 5: Import initial shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Tutorial 5: Import initial shapes

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

Page 3: Tutorial 5: Import initial shapes - ArcGISresources.arcgis.com/en/help/pdf/cityengine/10.2/... · 2013-12-05 · Shapes versus static models OBJ and Collada DAE files can be imported

Tutorial 5: Import initial shapesIn this tutorial:

• Part 1: Import Shapes from SHP / GDB

• Part 2: Import Shapes from OBJ

• Part 3: Import Volumes

• Part 4: Import Landmarks as Shapes

Download:

• Tutorial Data

• Tutorial PDF

Part 1: Import shapes from SHP/GDB

Import .shp files into CityEngine

Steps:

1. Open a new scene file File > New > CityEngine > CityEngine scene.

2. In the File Navigator, locate the .shp file footprints.shp in the folder data/shp_footprints/.

3. Drag and drop the file into the viewport.

4. Import the data without a projection: Use Raw data in meters.

Object attributes

CityEngine imports attributes along with shapefiles.

Steps:

1. Select a single footprint.

The Object Attributes are displayed in the Object Attributes pane of the Inspector.

Assign rule file and generate models

We will now generate simple extrusions on the imported footprints. The rule file extrude.cga uses the Object Attribute height toextrude the footprint to the defined height.

Steps:

1. Open the rule file and find the following code:

attr height = 10@StartRuleLot --> extrude(height)

2. Select all footprints in the 3D viewport.

3. Assign the rule via drag and drop.

Tutorial 5: Import initial shapes

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

Page 4: Tutorial 5: Import initial shapes - ArcGISresources.arcgis.com/en/help/pdf/cityengine/10.2/... · 2013-12-05 · Shapes versus static models OBJ and Collada DAE files can be imported

Watch the buildings be generated.

4. Alternatively, open footprints_from_shp.cej to see the finished scene.

Importing from file geodatabase

Importing data from a File Geodatabase is analogous to Shapefile import:

Steps:

1. Open a new scene file File > New > CityEngine > CityEngine scene. In the File Navigator, locate the FileGeodatabase folder footprints.gdb in the folder data.

Note: The .gdb file format is displayed as a folder in theNavigator.

2. Drag the folder footprints.gdb into the 3D viewport.

A dialog lets you choose which layers you want to import from the geodatabase.

During import, CityEngine will ask to choose a Scene Coordinate System. The coordinate system suggested in the dialogis taken from the data found in the Geodatabase.

3. Click Finish to import the selected layers.

The dataset in the provided Geodatabase is identical to the Shapefile content. You can now apply the same steps as described abovefor the Shapefile.

Importing PolylineZ Shapes with additional CGA attributes

Steps:

1. Open a new scene file File > New > CityEngine > CityEngine scene.

2. In the File Navigator, locate the .shp file sphereCity.shp in the folder data/sphereCity_shp/.

3. Drag the file into the 3D viewport.

During import, CityEngine will ask to choose a Data Coordinate System (the projection of the shapefile) for the filesphereCity.shp. The data in the shapefile is in meters, and not georeferenced, so choose Raw data in meters.

The shapefile sphereCity.shp has no .prj file, therefore CityEngine needs to ask the user to define the data coordinatesystem. This Dialog asks to choose a Scene Coordinate System.

Tutorial 5: Import initial shapes

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

Page 5: Tutorial 5: Import initial shapes - ArcGISresources.arcgis.com/en/help/pdf/cityengine/10.2/... · 2013-12-05 · Shapes versus static models OBJ and Collada DAE files can be imported

4. Choose Raw Data in meters. By using the same coordinate system for data and scene, no reprojection is applied to thedata on import.

A new Shape Layer called Shapes sphereCity appears in the Scene Editor, and the footprint shapes are visible in the3D viewport.

The polygons in this shapefile data have Z-values, resulting in 3D shapes in CityEngine.

Attributes

Two special attributes are defined in this dataset:

• ruleFile

• startRule

Note: Use this specific syntax already in your GIS application to define, which Rule Files and Start Rulesshould be assigned directly after the import. That way, you can save the time of manually assign them.This is a special import behavior.

The Attribute Table in the GIS application:

Tutorial 5: Import initial shapes

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

Page 6: Tutorial 5: Import initial shapes - ArcGISresources.arcgis.com/en/help/pdf/cityengine/10.2/... · 2013-12-05 · Shapes versus static models OBJ and Collada DAE files can be imported

Steps:

1. Select a single shape (one face of the sphere).

The Object Attributes are displayed in the Object Attributes pane of the Inspector.

Rule File and Start rule have been assigned automatically during import.

With rule file and start rule already assigned, we can now directly generate the models.

Steps:

1. Select all shapes of the sphereCity in the 3D viewport.

2. Generate the buildings.

Let’s change the Start Rule on individual shapes to change the generated model.

Steps:

1. Select a model in the 3D viewport.

2. In the Inspector, click the Start Rule Select Button.

3. In the Start Rule Dialog, choose Commercial as new Start Rule. StartRules (= rules with the @StartRule tag in CGAcode) are displayed in bold font.

Tutorial 5: Import initial shapes

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

Page 7: Tutorial 5: Import initial shapes - ArcGISresources.arcgis.com/en/help/pdf/cityengine/10.2/... · 2013-12-05 · Shapes versus static models OBJ and Collada DAE files can be imported

Part 2: Import shapes from OBJ

OBJ import

Steps:

1. Open a new scene file. Click File > New > CityEngine > CityEngine scene.

2. Locate and select the .obj file pompeii_footprints.obj in the older data/obj/.

3. Right-click the file and choose Import.

4. In the OBJ import dialog, uncheck Import as static model.

5. Click Finish.

Tutorial 5: Import initial shapes

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

Page 8: Tutorial 5: Import initial shapes - ArcGISresources.arcgis.com/en/help/pdf/cityengine/10.2/... · 2013-12-05 · Shapes versus static models OBJ and Collada DAE files can be imported

Assign rule file and generate models

We will now generate simple extrusions on the imported footprints. The rule file extrude.cga uses the Object Attribute height toextrude the footprint to the defined height.

Steps:

1. Select all footprints in the 3D viewport.

2. In the File Navigator, locate the cga file extrude.cga in the rules folder of the project.

3. Drag it onto the selected footprints in the 3D viewport.

The rule file will extrude all footprints to a height of 10.

Shapes versus static models

OBJ and Collada DAE files can be imported as shapes or as static models:

• Shapes: Serve as a base for CGA generation. A typical example is footprint data.

• Static Models: Can be scaled, rotated and translated after import, but cannot be processed further with CGA. Typicalexamples are landmark models.

If desired, open footprints_from_obj.cej to see the finished scene.

Part 3: Import volumes

Importing volumes as shapes

In some cases, it is easier to model volumes in an external application than to describe them with the CGA grammar. This tutorialshows how a crude building volume, modeled in Maya, can be imported into CityEngine, and how it’s facades can then be refinedusing CGA rules.

Note: An analogous workflow can be applied using multipatch data from .shp, .gdb or .dae (Collada)instead of OBJ data.

Importing

The building volume in the image below has been modeled with conventional methods in Maya, and exported as an .obj file:

Tutorial 5: Import initial shapes

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

Page 9: Tutorial 5: Import initial shapes - ArcGISresources.arcgis.com/en/help/pdf/cityengine/10.2/... · 2013-12-05 · Shapes versus static models OBJ and Collada DAE files can be imported

Import .obj file into CityEngine

Steps:

1. Open a new scene file. File > New > CityEngine > CityEngine scene

2. Locate and select the .obj file Building_1.obj in the folder data/obj/.

3. Right-click the file and choose Import.

4. In the OBJ import dialog, uncheck Import as static model.

5. Click Finish.

A new Shape Layer called Building_1 appears in the Scene Editor, and the data is displayed in the 3D viewport.

Tutorial 5: Import initial shapes

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

Page 10: Tutorial 5: Import initial shapes - ArcGISresources.arcgis.com/en/help/pdf/cityengine/10.2/... · 2013-12-05 · Shapes versus static models OBJ and Collada DAE files can be imported

Writing the rule file

The building volume's name Building_1 already defines its start rule Building. We therefore need to have Building as the startingrule. We need to align the coordinate system of the imported model to CityEngine’s yUp system. This is done with the help of theCGA command alignScopeToAxes(). Afterwards, we can identify the different faces of the imported volume with the component splitcomp(f) . We use the top selector for the roof faces, and the side selector for the facades. All we do at this step is color the Roofshape to see that the faces are identified correctly.

Building -->alignScopeToAxes(y)comp(f){top : color("#ff0000") Roof. | side : Facade. }

Steps:

1. Select the building shape in the 3D viewport.

2. In the File Navigator, locate the cga file importedVolume_01_markFaces.cga in the rules folder of the project.

3. Drag it onto the selected shape in the 3D viewport.

The imported building volume generated with a simple rule to identify the faces. Red : top faces (Roof) ; Grey : side faces (Facades):

Once the faces are identified correctly, we can continue the rule set. As these faces are modeled outside CityEngine, their orientationis not necessarily the way we need them for our rule operations. For the Facade rule, we therefore start with the CGA commandalignScopeToGeometry(zUp, auto). With this operation, the scope of the Facade shape is aligned to its lowest edge, with z facingoutward. This ensures that we operate with identically oriented scopes on all Facade faces.

Tutorial 5: Import initial shapes

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

Page 11: Tutorial 5: Import initial shapes - ArcGISresources.arcgis.com/en/help/pdf/cityengine/10.2/... · 2013-12-05 · Shapes versus static models OBJ and Collada DAE files can be imported

Facade -->alignScopeToGeometry(zUp, auto)split(y){3.5 : Groundfloor | {~3 : Floor}* }

The rule file importedVolume_02_facades.cga has a set of rules that add more details to the building's facades. Refer to theShapeGrammar tutorials to get help about writing CGA rules.

Let’s generate the building now again, using this rule set:

Steps:

1. Select the building shape in the 3D viewport.

2. In the File Navigator, locate the cga file importedVolume_02_facades.cga in the rules folder of the project.

3. Drag it onto the selected shape in the 3D viewport.

The scene file volume_from_obj.cej contains the imported model with the rule file assigned.

Part 4: Import landmarks as shapes

In case you have premodeled, textured assets you want to use in your scene, those can be imported as well.

Note: Supported formats are Wavefront .obj, Collada .dae, .kml and .kmz. (The last two are basically Colladafiles with georeference.)

Import .dae file into the CityEngine

Steps:

1. Open a new scene file. File > New > CityEngine > CityEngine scene

2. Locate and select the .dae file building_0.dae in the folder data/dae/.

3. Right-click the file and choose Import.

4. In the OBJ import dialog, uncheck Import as static model.

5. Hit Finish.

A new Shape Layer called building_0 appears in the Scene Editor.

Tutorial 5: Import initial shapes

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

Page 12: Tutorial 5: Import initial shapes - ArcGISresources.arcgis.com/en/help/pdf/cityengine/10.2/... · 2013-12-05 · Shapes versus static models OBJ and Collada DAE files can be imported

Converting static models to shapes

In case you have imported Static Models and would like to continue working on them with CGA code, you can always convert them toShapes.

To do so, right-click on the model, then Convert Models to Shapes.

You can do the same with Models which were generated with CGA.

Applying a CGA rule

If required, imported shapes can be processed further with CGA rules.

Steps:

1. Assign the rule file landmark.cga.

2. Generate the model.

There are 4 styles showing the different possibilities of the import process with CGA rules:

3. If desired, open landmark_as_shape.cej to see the finished scene.

Tutorial 5: Import initial shapes

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