UPDATE : You can view a demo of this rule file in action here via CityEngine’s webscene web viewer

This is a fun quick tip, instead of assigning a specific colour to each floor and building when not use the built in colorRamp function.  Search for it in the help file for detailed usage here’s how I’ve used it:

Heat island?

I’ve taken a centre point and coloured the rooftop of each building using the colorRamp function.   Basically it checks to see how far it is from a chosen point (fixed in the rule file) and normalises it so the value is between 0 and 1 and then uses that value to pick a colour in the depending on your chosen colorRamp.

The follow code is only extracts to get you going


attr CentreX = 0 //select a node (road junction) and copy values from the attributes to put here
attr CentreZ = 0 //select a node (road junction) and copy values from the attributes to put here

distanceToCenter = sqrt((initialShape.origin.px - CentreX )*(initialShape.origin.px - CentreX ) + (initialShape.origin.pz - CentreZ) * (initialShape.origin.pz - CentreZ))

attrColorValue(x) = 1/ (radiusLimit-radiusCentre) * (distanceToCenter - radiusCentre) //normalized between 0 and 1

	color (colorRamp("yellowToRed",attrColorValue(distanceToCenter)))

You can also use the same principles for building heights, for example giving each floor level an individual colour based on its elevation (scope.elevation instead of distanceToCenter).

Let me know if this needs more work, it seems good to me ….


Please enter your comment!
Please enter your name here

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