CityGen Script – Progress report #1
We were handed our scripting assignment the other week; you can see our brief below. At first glance it scared the hell out of me, I had no idea where to start!
Select an object, environment, or effect that would benefit from being procedurally modelled and/or animated such as, but not limited to:
- modelling of trees and vegetation
- terrain generation
- procedural modelling of buildings and/or cityscapes
- movement of waves, movement of gears, and/or drawing of spirals
You need to develop a Python script or a Python module using Maya and the Maya Python library of procedures which implements an algorithm(s) to model and/or animate you chosen object, environment, or effect.
I began by brushing up on a few of the basic lessons we were taught, eventually adapting those lessons to create a “Tower Generator” of sorts. By breaking it down to basics, I was able to easily understand the steps involved and began to realise that it really wasn’t as scary as it looked. My first script was about 450 lines of code, which I managed to write in a night of intense coding. To the left you can see a screen dump of what myfirst code created. It’s quite simplistic, with not much going in terms of detail, but I was pretty happy with it!

I started to add more detail, including creating proper windows with mullions and transoms, giving options for different style roofs (one peaked and one flat), and made sure that it was as dynamic as I could make it. I ended up with a pretty sufficient piece of code that could create a pretty decent range of style towers, see below:

After a few conversations with my dad and the demonstrators at uni I began to realise that I was going to have to change-up the code quite drastically to be able to create multiple towers, as the current code would conflict due to naming conventions. So I did another evening stretch thinning out my code, make it a lot more efficient and incorporating lists to help group the tower components. This worked like a charm, and I was able to create functions that would place the towers into a row, shown below.
The next step was to organise the towers into a grid. This turned out a little harder, taking me a while to grasp and eventually I heavily modified some code our lecturer had given us. When I got it to work, I was beaming! Nothing like solving a scripting problem that has been stumbling you for a few hours.
I then incorporated some simple ‘if’ functions to create dynamic chances for park areas to be created. I’m really happy with my progress, but I’ve got a good way to go yet. Next up is streamlining the naming conventions to include “blocks”, so that I can list and order the blocks into a city like manner with large towers in the center and shorter ones around the outside. If I get chance, I’d also like to create some more building types, e.g. a circular tower and maybe even some normal houses for suburb areas around the city.
I best get busy!


+ There are no comments
Add yours