Texturing lots with the terrain texture?

2839
7
Jump to solution
07-29-2013 12:10 PM
NicoleMiller
New Contributor III
Is it possible to do this? In dense urban areas, it's great to have textures for various shapes but in the case where the lot covers a nice expanse of land, it is sometimes more economical to just texture that lot with the imagery and let it be flat. I wouldn't mind leaving the terrain mesh exposed in those areas but in large databases the streets z-fight with the terrain so in those cases it is better to just texture the lots. Are there any rules for such a thing?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MatthiasBuehler1
Frequent Contributor
Sure !

Just change the values to your terrain's values ( select terrain layer, check values in Inspector. ) Note that CityEngine is yUp, not zUp as ArcGIS )

satelliteImage = "maps/mySatellitePic.jpg" satelliteImageData(data) =  case data == "SX"   : 1000  case data == "SZ"   : 1000  case data == "OX"   : 1000  case data == "OZ"   : -1000  else : 1  setupProjection(0,world.xz,satelliteImageData("SX"), -satelliteImageData("SZ"), satelliteImageData("OX"), satelliteImageData("OZ")) projectUV(0) texture(satelliteImage)


let me know if this works ..

matt

View solution in original post

0 Kudos
7 Replies
MatthiasBuehler1
Frequent Contributor
Sure !

Just change the values to your terrain's values ( select terrain layer, check values in Inspector. ) Note that CityEngine is yUp, not zUp as ArcGIS )

satelliteImage = "maps/mySatellitePic.jpg" satelliteImageData(data) =  case data == "SX"   : 1000  case data == "SZ"   : 1000  case data == "OX"   : 1000  case data == "OZ"   : -1000  else : 1  setupProjection(0,world.xz,satelliteImageData("SX"), -satelliteImageData("SZ"), satelliteImageData("OX"), satelliteImageData("OZ")) projectUV(0) texture(satelliteImage)


let me know if this works ..

matt
0 Kudos
NicoleMiller
New Contributor III
It says Mismatched Token (setupProjection)

When I looked up setupProjection in the help file, it seems like uvSet, axesSelector, texWidth, texHeight, widthOffset and heighOffset were assigned. I am not sure what it doesn't like when trying to create this rule.
0 Kudos
ThibaultThibault1
New Contributor II
This might be what you are looking for.
I hope it helps.

# 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)


Thibault
0 Kudos
MatthiasBuehler1
Frequent Contributor
Hi,

The thing I posted is a 'newer', more clean version of what Thibault also posted.

Though the code posted only contains the code to texture the shape. So I'm not sure if you did not add the rest of the code.

As you see in my code, the actual Rule is not defined ..

E.g. Roof -->

Let me know ..

m.
0 Kudos
ThibaultThibault1
New Contributor II
I am trying your code Matthias, but I don't understand where to put the code ?

If I add it to a rule in my cga file I get an error "No Viable Alt (satelliteImage)".
If I add it to the "Layer Attributes" of the "Lot" Layer (in my base "Building" Layer) I get 2 erros.


The code I found is to be used in a CGA file. It looks like that in mine :

version "2012.1"

const terrain_dimension_x = 2195.5
const terrain_dimension_z = 2034.5
const terrain_offset_x = 711075.750
const terrain_offset_z = -6654980.750

attr HAUTEUR = 0 #Mapped to an object attribute imported from the file GDB

@StartRule
Building -->
 extrude(HAUTEUR)
 comp(f) { top : Roof | side : Facade }

Roof -->
 setupProjection(0, world.xz, terrain_dimension_x, terrain_dimension_z)
 set(material.colormap, "texture/ortho16s.tif")
 projectUV(0)
 translateUV(0, -terrain_offset_x /terrain_dimension_x, -terrain_offset_z /terrain_dimension_z)
 scaleUV(0, 1, -1)

Facade --> ...
0 Kudos
MatthiasBuehler1
Frequent Contributor
Yes, the code goes in a CGA file, not in the terrain layer. You want to texture a part of the model which is created based on a shape.

So the code should look like :


satelliteImage = "maps/mySatellitePic.jpg"
satelliteImageData(data) =
 case data == "SX"   : 1000
 case data == "SZ"   : 1000
 case data == "OX"   : 1000
 case data == "OZ"   : -1000
 else : 1

@StartRule
Building -->
 extrude(HAUTEUR)
 comp(f) { top : Roof | side : Facade }

Roof -->
    setupProjection(0,world.xz,satelliteImageData("SX"), -satelliteImageData("SZ"),satelliteImageData("OX"),satelliteImageData("OZ"))
    projectUV(0)
    texture(satelliteImage)
    Roof.


Then, edit the 4 values with the values you find in your actual terrain layer.

Sorry that this was unclear. All start is hard .. 🙂

m.
0 Kudos
ThibaultThibault1
New Contributor II
It works great, your version of the code is shorter and clearer (I struggled to get the translation right in the previous code I used).

Thanks again for your quick reply.

--
Thibault
0 Kudos