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

Tutorial 5: Import initial shapes - Esri Supportdownloads.esri.com/.../tutorial_5...initial_shapes.pdf · Tutorial 5: Import initial shapes Download items • Tutorial data • Tutorial

  • Upload
    others

  • View
    24

  • Download
    2

Embed Size (px)

Citation preview

Tutorial 5: Import initialshapes

Copyright © 1995-2015 Esri. All rights reserved.

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

Tutorial 5: Import initial shapes

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

Tutorial 5: Import initial shapesDownload items

• Tutorial data

• Tutorial PDF

Import shapes from shapefiles and geodatabases

Import shapefiles into CityEngine

Steps:

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

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

3. Drag and drop the file into the viewport.

4. Import the data without a projection using 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 a rule file and generate models

You'll now generate simple extrusions on the imported footprints. The extrude.cga rule file uses the height object attribute to extrudethe 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.

Watch as the buildings are generated.

Tutorial 5: Import initial shapes

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

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

Import from a file geodatabase

Importing data from a file geodatabase is analogous to shapefile import.

Steps:

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

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

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

A dialog box appears allowing you to choose the layers you want to import from the geodatabase.

During import, CityEngine prompts you to choose a scene coordinate system. The coordinate system suggested in thedialog box is 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 shapefile steps described aboveto your file geodatabase import.

Import PolylineZ shapes with additional CGA attributes

Steps:

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

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

3. Drag the file into the 3D viewport.

During import, CityEngine prompts you to choose a data coordinate system (the projection of the shapefile) for thesphereCity.shp file. The data in the shapefile is in meters, and is not georeferenced, so choose Raw data in meters.

The sphereCity.shp file has no .prj file, so CityEngine also prompts you to define the scene coordinate system. TheSelect Scene Coordinate System dialog box allows you to do this.

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

Tutorial 5: Import initial shapes

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

A new shape layer called Shapes sphereCity appears in the Scene Editor, and the footprint shapes are visible in the 3Dviewport.

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 in your GIS application to define which rule files and start rules are assigneddirectly after import. This way, you can save time by not manually assigning them. This is a specialimport behavior.

The attribute table in your GIS application will look similar to the following:

Steps:

Tutorial 5: Import initial shapes

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

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

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

The rule file and start rule were assigned automatically during import.

You can now directly generate the models.

Generate the models

Steps:

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

2. Generate the buildings.

Tutorial 5: Import initial shapes

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

Change the start rule

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.The Set Start Rule dialog box appears.

3. In the Set Start Rule dialog box, choose Commercial as the new start rule. StartRules (rules with the @StartRule tagin CGA code) are displayed in bold font.

Import shapes from OBJ

OBJ import

Steps:

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

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

3. Right-click the file, and choose Import.The OBJ import dialog box appears.

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

Tutorial 5: Import initial shapes

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

5. Click Finish.

Assign a rule file and generate models

You'll now generate simple extrusions on the imported footprints. The extrude.cga rule file uses the height object attribute to extrudethe footprint to the defined height.

Steps:

1. Select all footprints in the 3D viewport.

2. In the File Navigator, locate the extrude.cga rule file in the rules folder of the project and drag it onto the selectedfootprints in the 3D viewport.The rule file extrudes 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 as follows:

• 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.

Tutorial 5: Import initial shapes

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

Import volumes

Import volumes as shapes

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

The building volume in the following image was modeled with conventional methods in Maya and exported as an .obj file:

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

Import an .obj file into CityEngine

Steps:

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

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

3. Right-click the file, and choose Import.The OBJ dialog box appears.

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

5. Click Finish.

Tutorial 5: Import initial shapes

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

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

Write the rule file

The building volume's name, Building_1, already defines its start rule Building. Consequently, you need to have Building as thestarting rule. You need to align the coordinate system of the imported model to CityEngine’s yUp system. This is done with thealignScopeToAxes() CGA command. After that's done, you can identify the different faces of the imported volume with thecomponent split comp(f) . You'll use the top selector for the roof faces and the side selector for the facades. All you do in this step iscolor the roof shape 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 importedVolume_01_markFaces.cga file in the rules folder of the project, and drag itonto the selected shape in the 3D viewport.The imported building volume is generated with a simple rule to identify the faces. Red: top faces (roof); Grey: sidefaces (facades):

Once the faces are identified correctly, you can continue the rule set. Since these faces are modeled outside CityEngine, theirorientation is not necessarily how you need them for your rule operations. For the Facade rule, start with thealignScopeToGeometry(zUp, auto) CGA command. With this operation, the scope of the facade shape is aligned to its lowest edge,with z facing outward. This ensures that you operate with identically oriented scopes on all facade faces.

Tutorial 5: Import initial shapes

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

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

The importedVolume_02_facades.cga rule file has a set of rules that adds more details to the building's facades. See theShapeGrammar tutorials for help regarding writing CGA rules.

Generate the building again using this rule set.

Steps:

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

2. In the File Navigator, locate the importedVolume_02_facades.cga file in the rules folder of the project, and drag it ontothe selected shape in the 3D viewport.The volume_from_obj.cej scene file contains the imported model with the rule file assigned.

Import landmarks as shapes

If 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 a .dae file into CityEngine

Steps:

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

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

3. Right-click the file, and choose Import.The OBJ import dialog box appears.

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

5. Click Finish.

A new shape layer called building_0 appears in the Scene Editor.

Tutorial 5: Import initial shapes

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

Convert static models to shapes

If you have imported static models and want to continue working on them with CGA code, you can convert them to shapes.

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

You can do the same with CGA-generated models.

Apply a CGA rule

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

Steps:

1. Assign the landmark.cga rule file.

2. Generate the model.The Style Manager dialog box shows the four style options for importing with CGA rules.

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

Tutorial 5: Import initial shapes

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