00:03Do want to learn how to...
00:04...procedural model building using the CGA shape grammar in the CityEngine?
00:09Well, then this tutorial is for you.
00:12You will write your first CGA rule file.
00:16And you will get to know the Rule Editor inside the CityEngine...
00:19...and, in the end, you will create a building that looks like this one in here.
00:24So, let's start from scratch and delete this one and create a new CGA grammar file.
00:36Now, it's already open here.
00:38So, to figure out at what rule we have to start...
00:41...you need to know the shapes envelope of this lot that we want to place the building on.
00:48So bring up the inspector and locate the ShapeSymbol here which is called "Lot."
00:52So, our first rule needs to be, "Lot."
00:57So we're going to do this...
01:00...and, with the first rule, all we do is just create a volume out of our Lot.
01:05So we do an extrude and showing you one of the nice features here of the Rule Editor...
01:10...which is, by pressing CTRL+SPACE, you get the command completion, which lists...
01:16...you all the features that there are and the parameters, so in case you're unsure...
01:21...about the naming and the parameters, you can always use this...
01:25...it's a good help to start with the shape grammar.
01:28I'm going to use the second one here.
01:31And enter a value of 11 units.
01:35I now have to assign our new rule file to the Lot.
01:42And I'm going to extrude for the first time.
01:45I am going to generate for the first time.
01:47So you see, this extruded volume here with the height of 11 units -- our first generation.
01:56Now, it's always a good idea to use attributes instead of absolute numbers in the rules.
02:02So, I'm going to add a new attribute called "Height," with a value of 11...
02:09...and replace this absolute number here with the attribute.
02:13I can generate again there won't be any difference because we have the same height.
02:17But if you look at inside the Inspector again, you see that here there's a new line...
02:23...the attribute height that we declared here is appearing here.
02:29And so it's very easy later on to change the height, for example, here in the Inspector.
02:35Okay, let's get on.
02:37We have to trigger a second rule now called "Building."
02:45And from now on I'm going to copy and paste rules so I don't have to type them.
02:49So this second rule, called "Building."
02:53We'll do a component split on this volume.
02:56So what it does is it gets from volume-to-face as we take all the side faces of our volume...
03:02...and trigger the Sidefacade rules on them.
03:05I'm going to save and generate the building again using the shortcut CTRL+G now...
03:13...and you see that now we only have the side facades.
03:15We don't care about the roof at the moment.
03:18Okay, let's head over to head over to the next rule: Sidefacade.
03:29You can see here that I again declared two new attributes...
03:32...called "groundfloor height," with the value of 4 and "floor height" with a value of 3.
03:37And the new Sidefacade rule?
03:40What does it do?
03:41It splits our facade vertically; marked by this y here into a ground floor...
03:50...and into floors.
03:51Note the asterisk mark here, which stands for a repeating split.
03:57This means that the upper floors are repeated as many times as they fit in.
04:04Note also the tilde sign here which marks that...
04:08...this floor height should only be matched approximately, so...
04:12...just make sure that the floors exactly fill the volume...
04:18...so floor height might differ a bit from the 3 meters due to the tilde character.
04:26Okay, and it's always a good thing to add some color in here just for testing purposes...
04:35...so what I do here is I added the red color on the GroundFloor so we will see... 59 00:04:42,700 --> 00:04:45,666 ...that this really is the GroundFloor as it is.
04:45And to show you how important the repeating split is, I'm going to...
04:51...make the building a bit higher now.
04:53Let's make it 21 instead of 11.
04:56Regenerate, and you see how the repeating split creates as many floors as fitting.
05:04Okay, let's change this back again.
05:07Regenerate back to normal.
05:10Okay, we go on with the floor rule.
05:23Again, a new attribute, tile width and the floor is again a split rule.
05:29This time horizontally, marked by the x.
05:32It splits every floor into a wall area, then a repeating tile area, and a wall area again.
05:41Save the rule, regenerate, and you see how our facade now has these wall areas here...
05:48...every floor has this wall area and the repeating tile elements.
05:57We will now go on and subdivide the tiles further.
06:06Again, a split in x and a split in y this time combined into one rule.
06:15What it does is just divides a single tile...
06:18...even more into wall elements and this window element here.
06:24Okay, now coming to the window rule.
06:35For this, look at have a short look here into the assets; do you see this window.obj?
06:42You can preview this in the inspector.
06:45The is a pre-modeled asset modeled outside of the CityEngine.
06:49And we want to insert this element here in our window area.
06:55So, what we need to do first is declare a new variable called, "window asset..."
07:01...which has here the path to this .obj file.
07:06And, as a second step, we're going to write a new rule called "window."
07:16And insert the window asset.
07:24And you see that this is not placed correctly...
07:28...so, what we do is, we do a small translation, minus set direction...
07:40...regenerate our building; this was too far, this looks quite good.
07:50Okay, so we already have a facade with some window elements in...
07:54...but now we want to have textures on the windows.
07:57Let's head over again to our asset folder and open the textures.
08:02See the window1.tif.
08:05See this texture we want to insert?
08:07On the windows?
08:11So again we define a new variable.
08:15Up here, called "window text," with a path to our texture.
08:20And we use the color map command to declare a texture.
08:27This one here; just before we insert the asset.
08:31Save the rule.
08:33And we have textures on the windows.
08:37Now the tutorials have shown how the rest of the facade texture as well.
08:41I'm going to skip this for now and just load this rule file and regenerate.
08:53And you see how their additional texture, mainly on the wall elements...
08:58...these are actually two layers of texture...
09:01...a dirt map with some dirt here on the floor and on the roof.
09:05And the brick texture on all elements.
09:11Now if you look at the polygon count here.
09:14This is quite a high polygon count coming from this complex asset here.
09:18So we're going to now create another version of this building with less detail.
09:25We're going to exchange this asset here with a normal texture plane.
09:32So I'm going to open up this Rule File here.
09:36And head over to the Window rule look at here the Outline...
09:42...that lists all the rules so you can easily jump to the Window rule.
09:47Okay, now what we do is...
09:51...we create a new attribute called "LOD," for "Level of Detail,' and declare it to 1.
09:57Now in the Window rule, you want to quickly be able to switch between the level of details.
10:02So we make a conditional rule in the window rule.
10:07So, let's say in the case in case that Level of Detail is bigger than 1, and bigger than 0...
10:15...we just use our old rule just inserting the asset.
10:35All we do is define material...
10:41...I'm going to define this texture here shortly; copied from the old rule.
10:54Here we go.
10:55So what we do is define the texture to be used here, but we don't do any...
11:00...any inserts of window assets.
11:02We need to set up the UVs because we don't have an asset yet.
11:04And "bake" it; please refer to the tutorial for details about that.
11:09Now, we have this new attribute here that we can switch here, so...
11:15...instead of using Level of Detail 1, the high resolution version is switched to 0.
11:25We regenerate the building and watch out for the windows.
11:29They're exchanged with normal planes here.
11:32You can go to the on texture mode to see this more detailed.
11:41Okay, as a last step now, we will add some random variation to our buildings.
11:48So go over to the scene, select delete this model; select some more lots here.
12:11Say, if we generate them now...
12:17...they all have the same height and are totally identical, which is not too realistic.
12:21So, we're going to bring up the rule set and change the height parameter...
12:30...to a random value going from 11 to 30, and reselect our block.
12:40Regenerate the buildings and you see how they get different heights.
12:44You can also test this on a single building by using the wand here.
12:51Every time you hit the wand, a new random seed is generated...
12:55...and the new random value for height is created.
Use Basic Shape Grammar in CityEngine
This video tutorial provides a guide to model buildings using the CGA shape grammar in CityEngine version 2008.2.
- Recorded: Dec 13th, 2011
- Runtime: 13:00
- Views: 2717
- Published: Dec 14th, 2011
- Night Mode (Off)Automatically dim the web site while the video is playing. A few seconds after you start watching the video and stop moving your mouse, your screen will dim. You can auto save this option if you login.
- HTML5 Video (Off) Play videos using HTML5 Video instead of flash. A modern web browser is required to view videos using HTML5.