About CityEngine Blog


CityEngine is a great tool that is able to create large scale models, mainly of cityscapes, quickly, and with the ability to make adjustments based on a rule file in a procedural manner.

I hope to show you some of the work I have done with CityEngine creating a variety of models across a range of projects. I have mainly used the software for planning applications but have learnt a great deal of the potential for other applications.

I want to concentrate on the writing of rule files which is the core use of CityEngine. Without rule files no 3D content can be generated and this is very important to understand. I will also strive to bring news and updates regarding CityEngine as well.

I hope you find what I share useful and please feel free to share and contribute your thoughts and experience.


Saturday, 7 September 2013

CityEngine Starter Project 4 - Building on a terrain and basic building detail



Building on a terrain

A section of code was now required so that the buildings take into account the terrain on which it sits. Presently the shapes sit on top of the terrain, sloping in a way which would create buildings that are not vertical. Essentially this section of code created a flat base on which the building can sit. On steep terrain it is very hard to deal with building model shapes in a simple way and would most likely need further operations to get an optimal output. However, I had chosen a fairly flat area so that it would not be an issue.

The next successor (ResidentialLot5) was extruded using the Extrude operation to a value (height) of 5m. The extruded block was then split in the vertical (y direction) as below:


ResidentialLot5 -->
     extrude(world.y, 5)
     split(y){~0.25 : ResidentialLot6 BaseKeeper | 5 : NIL}


A base had now been created on which the building could sit and be extruded. Note that I create two identical successors - ResidentialLot6 and BaseKeeper. This is so we can continue to build the residential house, whilst keeping the base as a separate piece. There are a few different ways to create a base and this one worked for me in this simple example. Some of the tutorial and example codes provided by Ersi show different ways to carry out a similar function and I'd advise having a look at these as well.




Another very commonly used operation now had to be used to select just the top surface of the base to continue building upon. A Comp(f) split operation allowed me to make this selection which also required another align the scope operation too. During Comp operations the previous alignment is lost and so I needed to reapply it.


ResidentialLot6 -->
     comp(f){top : alignScopeToGeometry(yUp, auto) ResidentialLot7}


Basic model detail

The ground work for the residential buildings was now complete. All I needed to do was extrude the footprint by a height value and carry out another Comp operation to select the top face for the roof. The final stage code for the residential buildings looked as follows:

ResidentialLot7 -->
     extrude(5.5) 
     comp(f){top : Roof | all : ResidentialLot8}
    
Roof -->
     roofHip(18.5, 0.4)

The roofHip operation created the roof geometry, the values for pitch and overhang could also  have been made into sliders. The residential buildings are now complete and the scene now looked like the image below:



The residential buildings were now complete. I had added a simple roof geometry that gave the buildings a more realistic look but really I could add a great deal more detail. The amount of detail that I add to models is very much scale and need dependant. The more models being generated generally the lower the amount of detail. Of course the level of detail (LOD) could be controlled by a slider, generating higher detail models when needed.

The next post will look at the commercial zone and how I used conditional and stochastic rules to give the models a more random feel.  I will also show how a function can be used in the code and run through some more complex split operations.

No comments:

Post a Comment