Modifying the Wrld map script

We are almost done; the last thing we need to do is let the Wrld Map script pull the last camera's position from our singleton SceneController. This means that we unfortunately have to modify the source of the Wrld Map script. Generally, we want to avoid modifying a third-party API, except that we have the source, and it really is our only option. Open up the WrldMap script, located in the Assets/Wrld/API folder, and follow along:

  1. Insert the following, between the lines identified:
using Wrld.Scripts.Utilities;  //after me
using Packt.HoloCore;
#if UNITY_EDITOR //before me
  1. Scroll down to the SetupApi method and insert the following code between the lines identified:
config.Collisions.BuildingCollision = m_buildingCollisions; //after me
config.DistanceToInterest = SceneController.Instance.position.GetAltitude();
config.LatitudeDegrees = SceneController.Instance.position.GetLatitude();
config.LongitudeDegrees = SceneController.Instance.position.GetLongitude();
Transform rootTransform = null; //before me
  1. All this does is set the map to the last position the camera was pointed at. You can see that we are using the SceneController singleton here to access the camera's last known position. You can see in the SetupApi method where a configuration object is defined and set. Hopefully, in the future, Wrld allows for this configuration to be passed into the script. If that was possible, we could just modify that configuration before it is passed to the WrldMap script, thus eliminating the need for us to add our own code in the class.
  2. Save the file and return to Unity. Check for any errors.
  1. Open the Build Settings dialog and ensure that both scenes are added, active, and in the order shown in the following excerpt:
Setting the scenes and scene order on Build Settings dialog
  1. Connect, build, and run the app. Since we are starting at 0, 0 in latitude and longitude spatial coordinates, the map will start just off the coast of Africa, which is 0, 0. Use a pinch touch gesture to zoom out until you see the global view of the world. Use a touch slide gesture to pan the map to North America, currently the best place to view WRLD data. Choose an area that is familiar and zoom in until you start to see 3D objects. Then, press the Switch button to switch the interface to MR and AR. You can switch back to the Main view by pressing Switch again. The following is an image showing the augmented reality mode and another user using the mixed reality mode with a HoloKit headset:
Augmented reality view of the application running
  1. We now have an app that lets a user navigate a map and then switch to view areas of interest in AR or MR mode. This works well, except that it would be better if the user started at their current position. In order to do that, we need to understand a bit more about mapping, GIS, and GPS, which we will cover in the next section.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.247.68