Before we start the code I used here came from a GIS mapping tutorial from CityEngine, I can’t seem to find the original page after them being merged with ESRI but you can see a cached copy of the page here.

First let us get some satellite imagery, I suggest you use an extract from an existing satellite imagery from your GIS. If you are taking the imagery from elsewhere you don’t need to follow all these steps…

  1. In ArcGIS — Draw a box using the Draw toolbar
  2. In ArcGIS — Select the underlying imagery in the Table of Contents right-click and select “Data –> Export Data”. Depending on what your are doing and the size of imagery you want you may want to use JPG and the settings below have worked for me. I suggest you experiment for the best results. I also suggest you export straight to the maps directory in your CityEngine project
  3. In CityEngine — Drag and drop from your maps directory into your CityEngine scene, it should come in under any data you already have. If it doesn’t check that in the Scene window the map layer does not have the eye crossed out also ensure that the show/hide map layers button is clicked.
  4. In CityEngine — Create a new rule file and copy this code in (be sure to change the relevant parts to your settings).
    # dimension of the satellite map
    const mapdimension_x = 1134.181 #change this to satellite image details
    const mapdimension_z = 939.650 #change this to satellite image details
    # offset of the satellite map
    const mapoffset_x = 597694.521 #change this to satellite image details
    const mapoffset_z = -3560369.907 #change this to satellite image details
    Lot-->
    extrude(rand(3,15)) Mass
    Mass -->
    # split building mass into roof and side faces
    comp(f){top : Roof | side : Facade}
    Roof --> Rooftex
    Rooftex --> 
    setupProjection(0, world.xz, mapdimension_x, mapdimension_z) 
    set(material.colormap, "maps/SATELLITEIMAGENAME.jpg") #change this 
    projectUV(0) 
    translateUV(0, -mapoffset_x/mapdimension_x, -mapoffset_z/mapdimension_z) 
    scaleUV(0,1,-1)
  5. In CityEngine — To get the x-size and x-offset numbers select the map layer in the Scene window (default location bottom left) and look at the Layer tab in the Inspector window (default right), copy these numbers to the const variables at the beginning of the rule file.
  6. In CityEngine — Now apply that rule (after changes to your shapes/lots) and generate your model!

 

14 COMMENTS

  1. Hi

    I was planning to make a before after of an irregular area. Is it possible in the newer version of CityEngine?

    PS: Have you a more detailed document of how to implement a model based on a satelite image?

    Regards
    Ezequias Rocha

  2. Hi

    I was planning to make a before after of an irregular area (not a square). Is it possible in the newer version of CityEngine?

    PS: Have you a more detailed document of how to implement a model based on a satelite image?

    Regards
    Ezequias Rocha

  3. very well idea ..I was planning to make a before after of an irregular area. Is it possible in the newer version of City Engine?can you tell me how i can do this,plz give me more details about it.

  4. Hi Elliot, your code is indeed very useful! However I have encountered spillover texturing to the facade as I would want the roof only to be textured. Any idea how to solve this? Appreciate your help. Thanks

    • Thanks! Depending on the data you are using, you need to use the component slip operation and only apply the texture rule to the ‘top’ :
      comp(f) { top : TOPTEXTURE | side : color(“#0000ff”) Side }

      Hope this helps!

    • Hi and thanks for reading, I think what you’re referring to is the viewport display resolution. This code used on satellite imagery you’ve downloaded will look fuzzy I think in the viewport. What you can do, if you really need a higher res in the viewport (exports are unaffected) is to go to Edit–>Preferences–>Procedural Runtime under the heading ‘Rendering’ and change the max texture height and width (default is 2048). It’s all to do with textures being stored in memory for display so obviously it has to be managed so you can make lots of large cities 🙂 Hope that helped!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.