Last Updated: Apr 24, 2017
- Test for Spatial Understanding Completeness
- Add Input Manager
- Finalizing Spatial Understanding
This section of the tutorial will wrap up spatial mapping and spatial understanding setting us up to place some holograms in the next section. First we will test to make sure we have a certain level of quality in our spatial understanding. Second when the spatial understanding is high enough quality the user can air tap to Finalize Spatial Understanding.
Test for Spatial Understanding Completeness
Open SpatialUnderstandingState.cs and make these changes:
These changes cause the Primary Text color to change from White to Yellow when spatial understanding criteria specified in constants is met. The first change is made to the Get property of PrimaryColor. In the previous version it always returned White. This makes a call to DoesScanMeetMinBarForCompletion to determine if the criteria have been met. In this method we call SpatialUnderstandingDll.Imports.QueryPlayspaceStats which returns an object of PlayspaceStats. This method compares the constants that have been added to determine if our spatial understanding is good enough for the application to continue.
Add Input Manager
To finalize spatial understanding the user will air tap. In order to detect user input from the HoloLens the HoloToolkit provides the Input Manager. Open the project in Unity and Add a new gameobject named “Control” in the Hierarchy. Drag the InputManager.prefab from the HoloToolkit (in the Input, Prefabs folder) into the new Control object. This results in a few gameobjects and components getting added to the Control Gameobject. This is everything that is needed to detect input from the HoloLens. The project should now look like this:
Finalizing Spatial Understanding
When the spatial understanding is good enough for our app, the message should both change color and instructions. The instructions will also change to tell the user to air tap in order to finish mapping.
Update SpatialUnderstandingState.CS to this:
The class now implements the interfaces IInputClickHandler and ISourceStateHandler. These interfaces contain OnInputClicked, OnSourceDetected, and OnSourceLost. The Start method is added making a call to the input manager telling it that this gameobject will subscribe to the input events. When these events occur the methods implemented by the interfaces are called notifying this class of user input. Visible hands detected are tracked so that the application can respond to the users hand coming into view. Air taps are detected allowing the user to finalize spatial understanding by calling RequestFinishScan which finalizes spatial understanding. Build the app and run it on the HoloLens. Map your room and air tap to finalize spatial understanding. Notice that after finalization is complete all of the gaps in the spatial map are approximated based on the rest of the spatial map. This is done to make the spatial understanding “water tight” so there is not ambiguity on how objects should be placed. Be careful not to allow the user to finalize with too many gaps in the spatial understanding or the results of object placement may be disappointing.
Tutorial IndexVersions: Unity 2017.1.0p5 | MixedRealityToolkit-Unity v1.2017.1.0 | Visual Studio 2017 15.3.2
|Unity 3D Project Creation||How to create a HoloLens project in Unity 3D|
|Source Control||Configure git for HoloLens / Unity work|
|Spatial Mapping||How to spatial map a Room|
|Object Surface Observer||Set up fake spatial map data for the Unity editor|
|TagAlongs and Billboarding||Tag along instructions to the user to force text on screen|
|Spatial Understanding||Add spatial understanding to get play space detail|
|Finalizing Spatial Understanding||Complete Spatial Understanding and Input Manager|
|Object Placement and Scaling||Find valid locations for holograms in the play space|
|Hologram Management||Manage the holograms you want to place in the world|
|Cursor and Voice||Add a cursor and voice commands|
|Occlusion||Add occlusion with the real world to your scene|
|Colliders and Rigidbodys||Add Colliders and RigidBodys to your holograms|