Okay this is a modification of this previous rule file it’s been one of my more popular posts in recent weeks.

So as the caption says I’ve used to methods to control colour and height of trees. Using the scatter function I place my tree and then colour via an elevation test and scale via a brightness test on some geology data.
Tree density is controlled by a tree per square metre variable.
Not wishing to put the whole rule out there, here are the relevant tests, if you know anything about CityEngine you’ll probably tell me there’s another way…
attr colourbyelevation = //test by heighest first > greater than xxx metres
case convert(y,pivot,world,pos,scope.sx,scope.sy,scope.sz) > 350 : "#ff0000"
case convert(y,pivot,world,pos,scope.sx,scope.sy,scope.sz) > 330 : "#ffff00"
case convert(y,pivot,world,pos,scope.sx,scope.sy,scope.sz) > 330 : "#00ff00"
case convert(y,pivot,world,pos,scope.sx,scope.sy,scope.sz) > 300 : "#00ffff"
case convert(y,pivot,world,pos,scope.sx,scope.sy,scope.sz) > 0 : "#0000ff"
else : "#00000"
attr treehegeotypeightbygeology =
case GeoType > 0 : 50
else : 25
The beauty of CityEngine is apparent when you realise this doesn’t have to be trees or elevations or geology, and you can combine these tests with other rules to make something truly complicated.
I’m not quite sure how to say this; you made it exrtlmeey easy for me!
Comments are closed.