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