FORUMS

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

By
-
-
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

`100:00:06,580 --> 00:00:15,596Continue working on your project, or open the file named CityBlocks_Bldgs-pattern.max that you were introduced to in the last movie.200:00:16,376 --> 00:00:19,341The scene shows the same familiar three city blocks.300:00:19,823 --> 00:00:27,514This time, you can see a variety of baked low-poly buildings that were created with Building Maker and scattered around the scene.400:00:28,070 --> 00:00:34,800In this case, the scattering was all manual. One could arguably use scatter methods that 3ds Max provides.500:00:34,940 --> 00:00:39,220One such way would be to use the Object Paint method from the ribbon.600:00:39,430 --> 00:00:44,910Another would be to use a PFlow particle system to scatter buildings as particles over a terrain.700:00:45,190 --> 00:00:53,280While the above methods are certainly valid, they do limit your control, such as choosing which particular building goes where.800:00:53,711 --> 00:01:00,010Sometimes, it is easier to simply place a building in its rightful spot using regular transform tools.900:01:00,463 --> 00:01:07,591More "generic-looking" buildings can then easily be duplicated using regular cloning methods, such as Shift+Move.1000:01:08,251 --> 00:01:14,877Once the buildings are in place, you would also want to hierarchically link them to their respective city blocks.1100:01:15,344 --> 00:01:20,477This would ensure that relocation of a city block also relocates its assigned buildings.1200:01:21,388 --> 00:01:30,700In 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.1300:01:31,325 --> 00:01:36,348From that point on, you simply use the Link tool to create a hierarchy.1400:01:45,131 --> 00:01:48,937Let's take a quick look at poly count as it stands right now.1500:01:49,716 --> 00:01:56,7053ds Max offers you the possibility to check for a scene's total poly count by using the 7 hotkey.1600:01:57,158 --> 00:02:04,724A yellow statistics overlay appears telling you this scene currently has about 370K polygons.1700:02:05,258 --> 00:02:07,926This seems excessive for what you see in the viewport.1800:02:08,286 --> 00:02:15,115Certainly, the street surfaces and buildings should account for a much smaller number given their topology and level of detail.1900:02:16,003 --> 00:02:23,007However, you need to remember that there's a fair amount of UDC components hidden from view at this time.2000:02:23,510 --> 00:02:27,400These are responsible for the high poly-count, given their sheer number.2100:02:28,123 --> 00:02:33,557Still, if you need to check poly-count on individual selections, here's what you do:2200:02:34,194 --> 00:02:38,379Click the Realistic label in the viewport and choose Configure.2300:02:39,144 --> 00:02:45,006Set the Statistics tab to use the Total + Selection option and click OK.2400:02:45,428 --> 00:02:53,558As you select one or more objects, you now get the total count as before, but you also get the selection poly and vertex count.2500:02:54,302 --> 00:03:01,354You can see in this case that the buildings and the streets without the UDC objects are only about 10000 polys.2600:03:02,216 --> 00:03:07,785You also get statistics about your viewport performance in the ways of a Frames-per-Second (FPS) count.2700:03:08,607 --> 00:03:15,237If you want to dismiss the statistics overlay, simply press 7 again. I'll leave it enabled for now.2800:03:15,863 --> 00:03:20,978Next, you create an area of 9 city blocks, in a 3x3 pattern.2900:03:21,541 --> 00:03:27,546Leave the left city block in place, but relocate the other two so that they stand on both sides.3000:03:28,031 --> 00:03:34,862Given that all city blocks are 300mx300m in size, use this information in the transform type-ins.3100:03:35,380 --> 00:03:43,122This means relocating one city block to -300m in X and the other to +300m in X.3200:03:44,211 --> 00:03:52,295Next, you are ready to duplicate them. Well, almost… because although relocating the ground plane relocates the children objects,3300:03:52,697 --> 00:03:57,175duplicating requires a broader selection, of both parents and children.3400:03:57,673 --> 00:04:01,605For that, you first need to make the UDC objects visible.3500:04:02,571 --> 00:04:09,311From the Unhide by Name dialog, type UDC in the search box, and select all urban design components.3600:04:10,044 --> 00:04:15,535Now that the UDC objects are in view, you may notice a significant drop in viewport performance.3700:04:15,862 --> 00:04:19,233That's ok, we'll hide these objects again soon enough.3800:04:19,860 --> 00:04:25,441For now, you need three copies of each city block to create a 3x3 grid.3900:04:26,144 --> 00:04:32,824Select a city block and its children by double-clicking an empty spot on any building lot.4000:04:35,082 --> 00:04:38,747Use Shift-Move to create a copy anywhere.4100:04:39,623 --> 00:04:45,098Now select the new city block surface and use transform type-ins to relocate it elsewhere.4200:04:45,440 --> 00:04:52,696In this example, I'll use X = 0 and Y = -3004300:04:54,753 --> 00:04:59,625Repeat the process again to have a total of three copies for each city block.4400:05:00,265 --> 00:05:06,864Scramble them a little bit so that no two city blocks of the same type are sitting side-by-side.4500:05:08,409 --> 00:05:18,083Remember to select all components to create duplicates, but only the city block surface when relocating.4600:05:36,010 --> 00:05:39,646Once that's done, hide the UDC objects from view again.4700:05:40,050 --> 00:05:47,479If you don't, performance is likely to take a hit now that you have more than one million polygons in the scene.4800:05:52,510 --> 00:05:59,422Not bad but it can use more variation. A look from top shows a predictable repetitive pattern.4900:06:00,040 --> 00:06:07,880If city blocks were to be randomly rotated by increments of 90 degrees, the pattern would be broken and appear more irregular.5000:06:08,485 --> 00:06:14,616Go to the top view and while you're at it, hide the buildings too, it will simply make things easier to see.5100:06:15,110 --> 00:06:19,750To hide the buildings, you use the same technique you used with the UDC objects before.5200:06:20,055 --> 00:06:26,168This time though, search for the "baked…" prefix to select all the buildings in the scene.5300:06:28,789 --> 00:06:36,884At this point, you can certainly rotate the city blocks manually to create an irregular pattern; it is easy enough with just nine blocks.5400:06:37,336 --> 00:06:41,860If you had more than nine, you could also, write a little script to help you out.5500:06:42,443 --> 00:06:45,635Open the MAXScript Listener window and type the following:5600:06:45,962 --> 00:06:52,296for i in 1 to selection.count do (5700:06:53,076 --> 00:06:55,436On an indented second line type:5800:06:55,951 --> 00:07:02,000obj=selection[i]5900:07:02,515 --> 00:07:09,270Basically these two lines of code take the current selection and assign it to a variable named obj6000:07:09,726 --> 00:07:11,891On a new indented line, type:6100:07:12,020 --> 00:07:18,650randomRotation=random 0 36200:07:18,970 --> 00:07:25,960This line adds a variable named randomRotation which can have the values 0, 1, 2 or 36300:07:26,586 --> 00:07:28,848On one more indented line type:6400:07:29,220 --> 00:07:45,640rotate obj (eulerAngles 0 0 (randomRotation * 90))6500:07:46,494 --> 00:07:55,370Basically, this line is where it all happens. The command "rotate" acts on the variable "obj" which is assigned to the current selection.6600:07:55,790 --> 00:08:10,334It 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.6700:08:10,969 --> 00:08:19,007This gives you random rotations of 0, 90, 180 or 270 degrees in Z on selected objects.6800:08:19,875 --> 00:08:25,442Finally, add a final line and close the parenthesis to finish off the script.6900:08:26,796 --> 00:08:34,598Right-click the main menu blank area and call back the toolbar you created earlier and that you named MyBuildingTools.7000:08:35,100 --> 00:08:39,390Select the new script you've written and drag it to the toolbar.7100:08:39,933 --> 00:08:42,521Give it a name if you want, 7200:08:51,124 --> 00:08:53,657and close the Listener window when done.7300:08:54,520 --> 00:08:59,372To test it out, select the nine city blocks and hit the new button.7400:08:59,824 --> 00:09:04,661Click away to randomize the rotations until you get a pattern you like.7500:09:07,452 --> 00:09:11,278If you want, you can even unhide the buildings, 7600:09:15,096 --> 00:09:18,371and still have a go at rotating the city blocks.7700:09:19,089 --> 00:09:23,989Save your file. Ultimately, you may elect to rearrange buildings after the fact.7800:09:24,458 --> 00:09:32,788This scene named CityBlocks_Bldgs-cam.max for example has a concentration of high-rise buildings near the center.7900:09:33,270 --> 00:09:40,153You will use this scene next to animate a camera before you liven up the mood by adding animated people using the Populate tool.8000:09:40,681 --> 00:09:43,786This will be a nice wrap-up to this long tutorial series.`
Posted By
Tags
• 3ds Max
• Animation
• Modeling
• Scripting
• 2014
• Environment
• Workflow

Got questions? Visit the Autodesk forums.

3ds Max 2019

3ds Max 2019

3ds Max 2016