Creating City Blocks in 3ds Max - Part 26 - Tiling and Rotating City Blocks

By
-
Login to Follow
-
Industry
  • Design Visualization
Subject
  • Animation
  • Modeling
  • Scripting
  • 2014
  • Environment
  • Workflow
Products
  • 3ds Max
Skill Level
  • Intermediate
Duration
10 min

Creating City Blocks in 3ds Max - Part 26 - Tiling and Rotating City Blocks

In this tutorial, you duplicate the three city blocks you already created into a 3x3 grid. To make an irregular pattern, you randomly rotate the nine city grids by 90 degree-increments. Although this is easy enough to do manually, you also learn to do the same using a few simple lines of script. This can become handy when you need to apply random rotation on multiple objects.


Notes

Transcript

1
00:00:06,580 --> 00:00:15,596
Continue working on your project, or open the file named CityBlocks_Bldgs-pattern.max that you were introduced to in the last movie.

2
00:00:16,376 --> 00:00:19,341
The scene shows the same familiar three city blocks.

3
00:00:19,823 --> 00:00:27,514
This time, you can see a variety of baked low-poly buildings that were created with Building Maker and scattered around the scene.

4
00:00:28,070 --> 00:00:34,800
In this case, the scattering was all manual. One could arguably use scatter methods that 3ds Max provides.

5
00:00:34,940 --> 00:00:39,220
One such way would be to use the Object Paint method from the ribbon.

6
00:00:39,430 --> 00:00:44,910
Another would be to use a PFlow particle system to scatter buildings as particles over a terrain.

7
00:00:45,190 --> 00:00:53,280
While the above methods are certainly valid, they do limit your control, such as choosing which particular building goes where.

8
00:00:53,711 --> 00:01:00,010
Sometimes, it is easier to simply place a building in its rightful spot using regular transform tools.

9
00:01:00,463 --> 00:01:07,591
More "generic-looking" buildings can then easily be duplicated using regular cloning methods, such as Shift+Move.

10
00:01:08,251 --> 00:01:14,877
Once the buildings are in place, you would also want to hierarchically link them to their respective city blocks.

11
00:01:15,344 --> 00:01:20,477
This would ensure that relocation of a city block also relocates its assigned buildings.

12
00:01:21,388 --> 00:01:30,700
In this case, the easiest way would be to select the city block in its entirety, and then removing the streets and building lots surface using Alt.

13
00:01:31,325 --> 00:01:36,348
From that point on, you simply use the Link tool to create a hierarchy.

14
00:01:45,131 --> 00:01:48,937
Let's take a quick look at poly count as it stands right now.

15
00:01:49,716 --> 00:01:56,705
3ds Max offers you the possibility to check for a scene's total poly count by using the 7 hotkey.

16
00:01:57,158 --> 00:02:04,724
A yellow statistics overlay appears telling you this scene currently has about 370K polygons.

17
00:02:05,258 --> 00:02:07,926
This seems excessive for what you see in the viewport.

18
00:02:08,286 --> 00:02:15,115
Certainly, the street surfaces and buildings should account for a much smaller number given their topology and level of detail.

19
00:02:16,003 --> 00:02:23,007
However, you need to remember that there's a fair amount of UDC components hidden from view at this time.

20
00:02:23,510 --> 00:02:27,400
These are responsible for the high poly-count, given their sheer number.

21
00:02:28,123 --> 00:02:33,557
Still, if you need to check poly-count on individual selections, here's what you do:

22
00:02:34,194 --> 00:02:38,379
Click the Realistic label in the viewport and choose Configure.

23
00:02:39,144 --> 00:02:45,006
Set the Statistics tab to use the Total + Selection option and click OK.

24
00:02:45,428 --> 00:02:53,558
As you select one or more objects, you now get the total count as before, but you also get the selection poly and vertex count.

25
00:02:54,302 --> 00:03:01,354
You can see in this case that the buildings and the streets without the UDC objects are only about 10000 polys.

26
00:03:02,216 --> 00:03:07,785
You also get statistics about your viewport performance in the ways of a Frames-per-Second (FPS) count.

27
00:03:08,607 --> 00:03:15,237
If you want to dismiss the statistics overlay, simply press 7 again. I'll leave it enabled for now.

28
00:03:15,863 --> 00:03:20,978
Next, you create an area of 9 city blocks, in a 3x3 pattern.

29
00:03:21,541 --> 00:03:27,546
Leave the left city block in place, but relocate the other two so that they stand on both sides.

30
00:03:28,031 --> 00:03:34,862
Given that all city blocks are 300mx300m in size, use this information in the transform type-ins.

31
00:03:35,380 --> 00:03:43,122
This means relocating one city block to -300m in X and the other to +300m in X.

32
00:03:44,211 --> 00:03:52,295
Next, you are ready to duplicate them. Well, almost… because although relocating the ground plane relocates the children objects,

33
00:03:52,697 --> 00:03:57,175
duplicating requires a broader selection, of both parents and children.

34
00:03:57,673 --> 00:04:01,605
For that, you first need to make the UDC objects visible.

35
00:04:02,571 --> 00:04:09,311
From the Unhide by Name dialog, type UDC in the search box, and select all urban design components.

36
00:04:10,044 --> 00:04:15,535
Now that the UDC objects are in view, you may notice a significant drop in viewport performance.

37
00:04:15,862 --> 00:04:19,233
That's ok, we'll hide these objects again soon enough.

38
00:04:19,860 --> 00:04:25,441
For now, you need three copies of each city block to create a 3x3 grid.

39
00:04:26,144 --> 00:04:32,824
Select a city block and its children by double-clicking an empty spot on any building lot.

40
00:04:35,082 --> 00:04:38,747
Use Shift-Move to create a copy anywhere.

41
00:04:39,623 --> 00:04:45,098
Now select the new city block surface and use transform type-ins to relocate it elsewhere.

42
00:04:45,440 --> 00:04:52,696
In this example, I'll use X = 0 and Y = -300

43
00:04:54,753 --> 00:04:59,625
Repeat the process again to have a total of three copies for each city block.

44
00:05:00,265 --> 00:05:06,864
Scramble them a little bit so that no two city blocks of the same type are sitting side-by-side.

45
00:05:08,409 --> 00:05:18,083
Remember to select all components to create duplicates, but only the city block surface when relocating.

46
00:05:36,010 --> 00:05:39,646
Once that's done, hide the UDC objects from view again.

47
00:05:40,050 --> 00:05:47,479
If you don't, performance is likely to take a hit now that you have more than one million polygons in the scene.

48
00:05:52,510 --> 00:05:59,422
Not bad but it can use more variation. A look from top shows a predictable repetitive pattern.

49
00:06:00,040 --> 00:06:07,880
If city blocks were to be randomly rotated by increments of 90 degrees, the pattern would be broken and appear more irregular.

50
00:06:08,485 --> 00:06:14,616
Go to the top view and while you're at it, hide the buildings too, it will simply make things easier to see.

51
00:06:15,110 --> 00:06:19,750
To hide the buildings, you use the same technique you used with the UDC objects before.

52
00:06:20,055 --> 00:06:26,168
This time though, search for the "baked…" prefix to select all the buildings in the scene.

53
00:06:28,789 --> 00:06:36,884
At this point, you can certainly rotate the city blocks manually to create an irregular pattern; it is easy enough with just nine blocks.

54
00:06:37,336 --> 00:06:41,860
If you had more than nine, you could also, write a little script to help you out.

55
00:06:42,443 --> 00:06:45,635
Open the MAXScript Listener window and type the following:

56
00:06:45,962 --> 00:06:52,296
for i in 1 to selection.count do (

57
00:06:53,076 --> 00:06:55,436
On an indented second line type:

58
00:06:55,951 --> 00:07:02,000
obj=selection[i]

59
00:07:02,515 --> 00:07:09,270
Basically these two lines of code take the current selection and assign it to a variable named obj

60
00:07:09,726 --> 00:07:11,891
On a new indented line, type:

61
00:07:12,020 --> 00:07:18,650
randomRotation=random 0 3

62
00:07:18,970 --> 00:07:25,960
This line adds a variable named randomRotation which can have the values 0, 1, 2 or 3

63
00:07:26,586 --> 00:07:28,848
On one more indented line type:

64
00:07:29,220 --> 00:07:45,640
rotate obj (eulerAngles 0 0 (randomRotation * 90))

65
00:07:46,494 --> 00:07:55,370
Basically, this line is where it all happens. The command "rotate" acts on the variable "obj" which is assigned to the current selection.

66
00:07:55,790 --> 00:08:10,334
It rotates the selected objects using euler angles of 0 in X, 0 in Y, and 90 degrees multiplied by either 0, 1, 2 or 3 assigned randomly in Z.

67
00:08:10,969 --> 00:08:19,007
This gives you random rotations of 0, 90, 180 or 270 degrees in Z on selected objects.

68
00:08:19,875 --> 00:08:25,442
Finally, add a final line and close the parenthesis to finish off the script.

69
00:08:26,796 --> 00:08:34,598
Right-click the main menu blank area and call back the toolbar you created earlier and that you named MyBuildingTools.

70
00:08:35,100 --> 00:08:39,390
Select the new script you've written and drag it to the toolbar.

71
00:08:39,933 --> 00:08:42,521
Give it a name if you want,

72
00:08:51,124 --> 00:08:53,657
and close the Listener window when done.

73
00:08:54,520 --> 00:08:59,372
To test it out, select the nine city blocks and hit the new button.

74
00:08:59,824 --> 00:09:04,661
Click away to randomize the rotations until you get a pattern you like.

75
00:09:07,452 --> 00:09:11,278
If you want, you can even unhide the buildings,

76
00:09:15,096 --> 00:09:18,371
and still have a go at rotating the city blocks.

77
00:09:19,089 --> 00:09:23,989
Save your file. Ultimately, you may elect to rearrange buildings after the fact.

78
00:09:24,458 --> 00:09:32,788
This scene named CityBlocks_Bldgs-cam.max for example has a concentration of high-rise buildings near the center.

79
00:09:33,270 --> 00:09:40,153
You will use this scene next to animate a camera before you liven up the mood by adding animated people using the Populate tool.

80
00:09:40,681 --> 00:09:43,786
This will be a nice wrap-up to this long tutorial series.

Posted By
Tags
  • 3ds Max
  • Animation
  • Modeling
  • Scripting
  • 2014
  • Environment
  • Workflow
0 Comments
To post a comment please login or register
*Save $70 per month on Autodesk's Suggested Retail Price (SRP) when purchasing 1 year term 3ds Max or Maya subscription.