2

I am working with CityEngine 2019.1 and would like to project a GeoTIFF as a texutre onto shaped roofs of 3D-buildings. Currently I am trying with the following code which essentials are described on https://doc.arcgis.com/en/cityengine/latest/cga/cga-setup-projection.htm:

solarMap = "data/Solarpotential_Buildings.tif"
attr FTYP = 0.0

const textureWidth = 1584.5 #Raster width in meters
const textureHeight = 1446.5  #Raster height in meters

offsetx = convert(x, scope, world, pos, 0, 0, 0) -
         (convert(x, scope, world, pos, 0, 0, 0) 
         % textureWidth)

offsetz = convert(z, scope, world, pos, 0, 0, 0) -
         (convert(z, scope, world, pos, 0, 0, 0) 
         % textureHeight)

Lot --> 

case FTYP == 2000.0 : color("#ffdddd") #Indicates the geometry is a wall
case FTYP == 3000.0 : Roof #FTYP = 3000 indicates the geometry is a roof
else : color("#aaaaff") #All other geometries

Roof -->

    # color, uv set 0
    setupProjection(0, world.xy, textureWidth, 
                   textureHeight, -offsetx, offsetz)
    # texture(solarMap)
    projectUV(0) #0 is used for colormaps so this should be correct
    scaleUV(0, 1, 1)
    set(material.colormap, solarMap)

I have tried lots of different variations within setupProjection() and scaleUV(), like world.xz, world.yz, etc. or without offsets or different scaling factors, but the GeoTIFF is always misaligned or distorted somehow. For example like this:

enter image description here

The colormap you can see below the buildings is the actual GeoTIFF added as plain texture for reference.

While doing it manually via Shape texturing tool and choosing Projection as Mode, the GeoTIFF is projected correctly.

enter image description here

enter image description here

All files as well as the scene do have the same CRS. Studying the linked help section and other related articles provided by ESRI didnt bring me any further so far. Basically, the error must be somewhere within this part of code:

setupProjection(0, world.xy, textureWidth, 
               textureHeight, -offsetx, offsetz)
projectUV(0)
scaleUV(0, 1, 1)
set(material.colormap, solarMap)

How can I achive this correctly projected result by using CGA rules?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.