Exercise - Build wind farm terrain
Unity Prefabs let you create, configure, and store a GameObject as a reusable project asset. The dynamic terrain Prefab Asset is built using the Microsoft Maps SDK and connects to the Bing Maps 3D service. To get started, open up the blank MainScene we've included for you to develop throughout the learning path.
Open the MainScene scene
Download and Unzip the compressed folder from GitHub and take note of the folder location to where you extracted the project
In the Project panel, select Assets > Scenes > MainScene. Any Save actions will overwrite the original MainScene, which is the intent of this learning path.
The Assets > Scenes > CompletedScene contains configuration, scripts, and relevant pointers to the final Scene. This Scene has been supplied to provide a ‘complete’ Scene representing all components and assets, but it will still require further configuration before it can be used (viz., Maps SDK and Azure Services).
We'll explore the benefits of static maps and dynamic maps in this module, starting by adding the static terrain and then adding the Maps SDK terrain.
Add static terrain
In the Project Panel, open the Assets > Art > Prefabs folder
Drag the Terrain Model named Static Terrain into the scene editor window
With the Static Terrain object selected in the Hierarchy Panel on the left, the Inspector window on the right will show the Position, Rotation, and Scale parameters under the Transform section. Position the terrain using the Position coordinates
(X = -1.25, Y = -0.59, Z = 2)so that the Static Terrain is to the front left of the user at startup.
Save the scene under the File > Save menu option.
You now have the static terrain Prefab loaded and available for use in your app. Next, you can load the Bing Maps dynamic terrain into the Scene.
Create Bing Maps account
If you haven’t already, you need to create a Bing Maps account. You'll use that account to access the Microsoft Bing Maps Dev Center to generate a Developer Key, which is a code used to authenticate with the map service. The app you build will connect to that map service using your Bing Maps account.
When you create a Developer Key, be sure to select Basic as the key type and Windows Application as the Application Type.
Add dynamic terrain and configure Bing Maps data feed
From the Project panel, drag in the following Prefab into the Hierarchy panel:
- Assets > Art > Prefabs > Bing Maps Design
Select the new instance of the Prefab in the hierarchy panel, and expand the Map Session component in the Inspector and enter the Developer Key obtained in the previous section.
You may need to select another item in the hierarchy, then select Bing Maps again to refresh.
Expand the Map Renderer (Script) component in the Inspector and set the following Location and Map Layout settings:
Property Value Latitude 36.69 Longitude -78.36 Zoom Level 15.5 Property Value Map Shape Cylinder Local Map Radius 1 Local Base Height 0.3
Expand the Transform component in the Inspector and validate the position of the map using the Position coordinates (X = 0, Y = -0.7, Z = 2) so the two maps are placed side by side.
Save the scene under the File > Save menu option. If prompted, save your Scene in the Scenes folder.
In the Scene, you should have both the Static and Dynamic terrain loaded. Navigate the Scene using your mouse and/or keyboard.
When you are navigating in the Scene panel, you may find your Assets of interest become set in awkward positions. To return focus and zoom to a particular Asset, select the object in the Hierarchy panel, then click in the Scene window. Next, press Shift-F and your Scene will center on and zoom into the selected Asset. The same effect can be achieved by double-clicking an Asset in the Hierarchy panel.
Press the Play button and navigate the Game panel.
Navigating within the Game panel can be achieved using the MRTK input simulation service. Although many of the navigation techniques can be achieved using a standard keyboard and mouse, a wheel mouse simplifies navigation.
Observe any differences between the Static Terrain and Dynamic Terrain (for example, endless terrain and contour lines in the Bing Maps terrain v. higher resolution imagery in the Static Terrain)
Remove static terrain
- Right-click the Static Terrain in the Hierarchy panel and select Delete.
- Save the Scene under the File > Save menu option. This will overwrite the original Scene.