Select to view content in your preferred language

How to drape a raster over 3D models in CityEngine?

3147
11
Jump to solution
08-21-2018 03:04 PM
NicholasMartinez1
Emerging Contributor

Hello GeoNet,

I have 3D buildings modeled in CityEngine. I created a heat map of office locations and would like to drape the raster of that map over the 3D buildings to show where the concentrations of offices are. This would be much quicker than writing a rule file to color gradient the buildings in my opinion because the geospatial component of office clusters is spread across the raster whereas coloring the buildings would lose the spatial component. Any ideas on how to get a raster over a non-terrain 3D model?

Thanks

0 Kudos
1 Solution

Accepted Solutions
MatthiasBuehler3
Regular Contributor

Hi Nicholas,

This is how:

- you find the terrain extent in the inspector (select the terrain layer), edit the values in the code below.

- your heat map needs exactly the same extent as the satellite picture with this method.

- this code runs metric, maybe some things need to be adapted for feet projections.

CODE:

****************************************************

terrainExtentData(data) =
   case data == "SX" : 15000
   case data == "SZ" : 15000
   case data == "OX" : 3224458.982
   case data == "OZ" : -5016876.625
   else : 1

ProjectGeorefImage -->
      setupProjection(0,world.xz,
          terrainExtentData("SX"),
         -terrainExtentData("SZ"),
          terrainExtentData("OX"),
          terrainExtentData("OZ")
      )
      projectUV(0)
      texture("maps/myMap.jpg")
 

*****************************************************

Cheers!

matt

------------------------------------------------------------------------------------------------------------------
matthias buehler || ceo & co-founder || msc. arch. eth zurich
------------------------------------------------------------------------------------------------------------------

vrbn AG – official esri partner 
|| www.vrbn.io || winterthurerstrasse 53 || 8610 uster || switzerland
+41 78 930 04 07 || matthias.buehler@vrbn.io || @vrbnio @mattb3d

View solution in original post

11 Replies
MatthiasBuehler3
Regular Contributor

Hi Nicholas,

This is how:

- you find the terrain extent in the inspector (select the terrain layer), edit the values in the code below.

- your heat map needs exactly the same extent as the satellite picture with this method.

- this code runs metric, maybe some things need to be adapted for feet projections.

CODE:

****************************************************

terrainExtentData(data) =
   case data == "SX" : 15000
   case data == "SZ" : 15000
   case data == "OX" : 3224458.982
   case data == "OZ" : -5016876.625
   else : 1

ProjectGeorefImage -->
      setupProjection(0,world.xz,
          terrainExtentData("SX"),
         -terrainExtentData("SZ"),
          terrainExtentData("OX"),
          terrainExtentData("OZ")
      )
      projectUV(0)
      texture("maps/myMap.jpg")
 

*****************************************************

Cheers!

matt

------------------------------------------------------------------------------------------------------------------
matthias buehler || ceo & co-founder || msc. arch. eth zurich
------------------------------------------------------------------------------------------------------------------

vrbn AG – official esri partner 
|| www.vrbn.io || winterthurerstrasse 53 || 8610 uster || switzerland
+41 78 930 04 07 || matthias.buehler@vrbn.io || @vrbnio @mattb3d

NicholasMartinez1
Emerging Contributor

Hey Matthias,

Thanks for the advice. I'm not sure if this will work. I haven't tried yet, but it seems like this would generate a terrain, which would be under the 3D models of our buildings. What I'm looking to do is drape it over the 3D buildings (not the terrain) as if I'm applying textures to the buildings themselves, but en masse. 

0 Kudos
MatthiasBuehler3
Regular Contributor

Hi ..

it will work .. 😉

the workflow has nothing to do with the terrain per se. you just use a georeferenced terrain to get the proper extent values for a heat map, which gets projected onto the models via CGA.

CGA does not know georeferencing, therefore you have to 'feed' that to CGA.

the above workflow does that. the only stipulation in this workflow is that the texture shows the same geographic extent as the terrain - which means the terrain you use to get the values should contain all buildings you wanna texture.

cheers!

matt

------------------------------------------------------------------------------------------------------------------
matthias buehler || ceo & co-founder || msc. arch. eth zurich
------------------------------------------------------------------------------------------------------------------

vrbn AG – official esri partner 
|| www.vrbn.io || winterthurerstrasse 53 || 8610 uster || switzerland
+41 78 930 04 07 || matthias.buehler@vrbn.io || @vrbnio @mattb3d

0 Kudos
NicholasMartinez1
Emerging Contributor

Thanks Matthias,

It took a few moments to realize this would be a rule applied to the buildings rather than the terrain. I got it to work, but forgot that rasters default white to black in CE. How can I change the color ramp on the raster?

0 Kudos
MatthiasBuehler3
Regular Contributor

Hi,

I assume you mean changing the image visualization based on the values? CE can't do that.

I recomment to use a default RGB jpg that you have exported from GIS. If you use geotif as format, I'd recommend 8 bit per channel.

Cheers,

matt

------------------------------------------------------------------------------------------------------------------
matthias buehler || ceo & co-founder || msc. arch. eth zurich
------------------------------------------------------------------------------------------------------------------

vrbn AG – official esri partner 
|| www.vrbn.io || winterthurerstrasse 53 || 8610 uster || switzerland
+41 78 930 04 07 || matthias.buehler@vrbn.io || @vrbnio @mattb3d

0 Kudos
NicholasMartinez1
Emerging Contributor

Hi Matthias,

Thank you for your help. That fixed it. One last thing, how do OX, OZ, SX, and SZ match up to the extents? I projected the raster to web mercator to get meters, but it's not displaying over the buildings the way it does on the 2D map. I'm guessing I'm not inputting the extents to the OX, OZ, SX, and SZ correctly. Tried mixing the extent numbers around, which kept changing the position of the raster on the buildings, but haven't gotten it to look close enough to how it should look.

Thanks

0 Kudos
MatthiasBuehler3
Regular Contributor

Hi Nicholas

You have a given terrain. When you select the terrain layer, in the inspector you can see the extent:

Offset X / Z and Scale X / Z.

What may be a bit confusing is that CityEngine works yUp internally (Y = direction of gravity, elevation).

Also, make sure that the little pivot icon has the black dot in one of the corners, not in the middle. It should be by default. You find this icon in the terrain layer at the top. Looks a bit like this, about 16x16 pixels big:

[]     []     []

[]     []     []

   []     []

So just grab those 4 values of your terrain and paste them in the rule file (there are some values there, but they don't work for you.

Let me know if this helps.

matt

------------------------------------------------------------------------------------------------------------------
matthias buehler || ceo & co-founder || msc. arch. eth zurich
------------------------------------------------------------------------------------------------------------------

vrbn AG – official esri partner 
|| www.vrbn.io || winterthurerstrasse 53 || 8610 uster || switzerland
+41 78 930 04 07 || matthias.buehler@vrbn.io || @vrbnio @mattb3d

0 Kudos
NicholasMartinez1
Emerging Contributor

Hey Matthias,

I actually put the extents in the way the terrain had laid out after you explained this to me, and for some reason, it's still not displaying properly. I'm including 3 images. One of the buildings with the heatmap as a texture, one of the heatmap as the terrain, and one of the buildings on top of the heatmap terrain so you can see how the colors are inverted. Hope you can help.

0 Kudos
NicholasMartinez1
Emerging Contributor

Additionally, here's a screenshot of the rule file and terrain data.

0 Kudos