Export City with Individualized Buildings

1562
5
Jump to solution
03-02-2023 09:56 AM
TBraff
by
New Contributor II

Hello, this is a mix for a question with CityEngine and the Unity SDK.

I am trying to generate a city from OSM data using CityEngine, (Toronto, for example), apply textures, and export the results ideally as an SLPK file to use in the ArcGIS Unity SDK or an FBX file. However, when exporting the buildings they are not individualized and are merged based on whether they share materials/textures. After playing around with some settings, I could only export it as an FBX and setting it to not merge anything, but that results in every individual face/facade of the buildings being selectable rather than the whole building (and generates thousands more meshes which overload Unity). I've attached example images.

I know it is possible to export each individual building as its own FBX/OBJ file, but that doesn't maintain their position in the world and I would have to manually place every single building. I need the in-between of these results, where the building itself is selectable. Possibly in the future it would be useful to slice the building meshes so that individual stories in multistory buildings are selectable, but for now I just need each building as its own whole.

Is there a combination of export settings I'm missing, or possibly a rule package/script I could use in CityEngine to export the buildings as individually selectable?

0 Kudos
1 Solution

Accepted Solutions
JonasObertuefer
Esri Contributor

hi again,

It worked fine for me in a quick test using shape groups, see attached screenshot from unity 2021.3.19f1 and the FBX Export settings used in CityEngine 2022.1

You can ignore my comment about script based export above. I think you don't need it for your purpose. If you want to export one fbx file per start shape you simply set the global offset once under geometry settings.

To get a reasonable offset value for an unity scene around 0/0//0:

  1. Select all objects in your scene (CTRL + A)
  2. CTRL + E to Export Models -> FBX Export
  3. Geometry Settings -> Global Offset -> Hit Center
  4. Write down the values somewhere (or save a preset) and use them for all your exports of this scene

Then in Unity just add all the FBXs to your scene

Hope this works for you,

Cheers
Jonas

 

To center your scene around 0/0/0

View solution in original post

5 Replies
JonasObertuefer
Esri Contributor

Hi @TBraff,

Have you tried set the Create Shape Groups option under Granularity Settings in the FBX export?

To work with position & individual files for each building please have a look at this tutorial:
https://doc.arcgis.com/en/cityengine/latest/tutorials/tutorial-12-scripted-report-export.htm

Pretty sure you can then script the placement in Unity.

cheers
Jonas

0 Kudos
TBraff
by
New Contributor II

I've tried creating shape groups, but it results in nothing being visible in the FBX file. I'm looking into the tutorial you linked, how would I access the fbx file's reported variables? I'm mainly using the Building_From_OpenStreetMap.cga rule file to generate the buildings, and it looks like in the script it reports various OSM tag data that I can maybe extend to reporting the XYZ position/rotation/scale of the current building it's generating. 

How would I go about scripting their placement in Unity? Is there a way to export all of the building's attributes into a clean CSV file maybe so I could parse through and place each individual FBX file in their building's location? I would need to know how to associate an FBX file with a specific building/object ID.

0 Kudos
JonasObertuefer
Esri Contributor

hi again,

It worked fine for me in a quick test using shape groups, see attached screenshot from unity 2021.3.19f1 and the FBX Export settings used in CityEngine 2022.1

You can ignore my comment about script based export above. I think you don't need it for your purpose. If you want to export one fbx file per start shape you simply set the global offset once under geometry settings.

To get a reasonable offset value for an unity scene around 0/0//0:

  1. Select all objects in your scene (CTRL + A)
  2. CTRL + E to Export Models -> FBX Export
  3. Geometry Settings -> Global Offset -> Hit Center
  4. Write down the values somewhere (or save a preset) and use them for all your exports of this scene

Then in Unity just add all the FBXs to your scene

Hope this works for you,

Cheers
Jonas

 

To center your scene around 0/0/0

TBraff
by
New Contributor II

Bingo! Got it all exported into one FBX file and everything is neatly organized into their own buildings. Only weird thing is now the textures aren't being exported alongside them, but I can probably fix that with some more export setting tweaks. Thank you so much!

0 Kudos
JonasObertuefer
Esri Contributor

Glad you made it work. If you embed the textures into the FBX you need to extract them again inside Unity. Select the FBX asset and then in the Inspector click on Extract Textures... & Extract Materials...