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 overwrite the original MainScene, which is the intent of this learning path.
Note
The Scene in 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 still requires further configuration before you can use it (viz., Maps SDK, and Azure Services).
We'll explore the benefits of static maps and dynamic maps in this module. We'll start 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 following Position coordinates: X=-1.25, Y=-0.59, Z=2. These coordinates place the Static Terrain in front of and to the left of the user at startup.
Use the File > Save menu option to save the scene.
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 the Assets > Art > Prefabs > Bing Maps Design Prefab into the Hierarchy panel.
Select the new instance of the Prefab in the Hierarchy panel and expand the Map Session component in the Inspector. Enter the Developer Key you obtained in the previous section.
Note
You might need to select another item in the hierarchy, then select Bing Maps again to refresh.
Expand the Map Renderer (Script) component in the Inspector window 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 following Position coordinates: X=0, Y= 0.7, Z=2. This places the two maps side by side.
Use the File > Save menu option to save the Scene. 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.
Note
When you're navigating in the Scene panel, you might find that 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 in to the selected Asset. You can achieve the same effect by double-clicking an asset in the Hierarchy panel.
Select the Play button and navigate the Game panel.
You can navigate in the Game panel by using the MRTK input simulation service. Although you can achieve many of the navigation techniques by 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 versus higher resolution imagery in the Static Terrain).
Remove static terrain
- Right-click the Static Terrain in the Hierarchy panel and select Delete.
- Use the File > Save menu option to save the scene. This overwrites the original Scene.