Skip to content

Commit a30cf06

Browse files
author
Robert Onulak
committed
Example scenes with a README on steps for testing saving and loading Spatial Mapping and Spatial Understanding meshes.
1 parent 8e4cd6a commit a30cf06

15 files changed

+1031
-0
lines changed

Assets/HoloToolkit-Examples/SavingSpatialMeshes.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
4+
[RequireComponent(typeof(TextMesh))]
5+
public class DebugText : MonoBehaviour
6+
{
7+
private TextMesh mText;
8+
9+
private void Awake()
10+
{
11+
mText = GetComponent<TextMesh>();
12+
}
13+
14+
public void SetText(string text)
15+
{
16+
mText.text = text;
17+
}
18+
}

Assets/HoloToolkit-Examples/SavingSpatialMeshes/DebugText.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using UnityEngine;
2+
using UnityEngine.SceneManagement;
3+
4+
public class LevelManager : MonoBehaviour
5+
{
6+
public void LoadNextScene()
7+
{
8+
int sceneIndex = SceneManager.GetActiveScene().buildIndex + 1;
9+
if (sceneIndex >= SceneManager.sceneCountInBuildSettings)
10+
{
11+
sceneIndex = 0;
12+
}
13+
14+
SceneManager.LoadScene(sceneIndex);
15+
}
16+
}

Assets/HoloToolkit-Examples/SavingSpatialMeshes/LevelManager.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# SaveSpatialMapping Example
2+
This example shows how to save the meshes generated using the Spatial Mapping and Spatial Understanding components directly on the HoloLens.
3+
4+
#### SpatialMappingObserver Modifications
5+
Underneath the hood SpatialMappingObserver contains a new method, SaveSpatialMeshes(string fileName). Calling this function with a string name will save a enumeration of meshes to a .room file on the HoloLens.
6+
7+
#### FileSurfaceObserver Modifications
8+
Adds a button for quickly accessing the AppData folder of the Unity project. This is the directory where the FileSurfaceObserver looks for .room files to load.
9+
10+
#### Demo Scenes
11+
SaveSpatialMapping and SaveSpatialUnderstanding scenes are setup exactly the same, except they are using the different spatial meshes.
12+
13+
Tip for testing: Add both scenes to be built into the application. The LevelManager script will make it easy to navigate between scenes if you say, "Load Next Scene". Therefore you can just install the app once and capture the meshes from the different scenes. The Room (.room) files are saved out different for each scene so you will not overwrite the other mesh.
14+
15+
Process: Scan, save, download, and load.
16+
17+
1. Install the app on a device.
18+
2. Scan room.
19+
3. When your ready to save the mesh say, "Capture Mesh". Text will display to acknowledge the completion of the action.
20+
4. Pull the saved mesh off of the device by going to the Device Portal. Navigate to System > File Explorer > User Files > LocalAppData > <Your App> > RoamingState. This is where .room files are saved.
21+
5. Download the .room file to your computer in the location opened by FileSurfaceObserver's "Open File Location" button.
22+
6. Press the Play button.
23+
7. Click in the Game window to make sure it has focus.
24+
8. Press the L key to load the mesh into the scene.
25+
9. Navigate back to the Scene window so you can inspect the mesh loaded.
26+
27+
#### Convert Selection To Wavefront (.obj)
28+
After following a demo to download a .room file you will be able to convert that .room file to a Wavefront (.obj). This flow is based off the highlighted selection within Unity's Hierarchy panel.
29+
30+
Process: Select GameObject(s) with MeshFilters then export.
31+
32+
1. Highlight the GameObject(s) containing MeshFilters you want to export to the Wavefront (.obj) file.
33+
2. In the Unity menu context, click HoloToolkit > Export > Export Selection To Wavefront (.obj).
34+
3. File / Folder menu will open and there will be a file named "Selection.obj" containing all MeshFilters saved in a single file.
35+
36+
Note that this could be done while in play mode. Therefore you could enter play mode, load any saved spatial meshes, select said meshes in the hierarchy panel, then export selection to file.
37+
38+
#### Convert Room (.room) To Wavefront (.obj)
39+
After following a demo to download a .room file you will be able to convert that .room file to a Wavefront (.obj). In this particular process it will directly reference the Room (.room) files saved on the HoloLens.
40+
41+
Process: Download then export.
42+
43+
1. In the Unity menu context, click HoloToolkit > Export > Export Room (.room) To Wavefront (.obj)...
44+
2. A open file dialog will pop up in the location where Room (.room) files are saved / located for your project.
45+
3. Select the Room (.room) file you wish to export.
46+
4. Click Open.
47+
5. File / Folder menu will open and you should see a Wavefront (.obj) file with the same file name as the Room (.room) file selected in step 3.

Assets/HoloToolkit-Examples/SavingSpatialMeshes/README.md.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!29 &1
4+
SceneSettings:
5+
m_ObjectHideFlags: 0
6+
m_PVSData:
7+
m_PVSObjectsArray: []
8+
m_PVSPortalsArray: []
9+
m_OcclusionBakeSettings:
10+
smallestOccluder: 5
11+
smallestHole: 0.25
12+
backfaceThreshold: 100
13+
--- !u!104 &2
14+
RenderSettings:
15+
m_ObjectHideFlags: 0
16+
serializedVersion: 7
17+
m_Fog: 0
18+
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
19+
m_FogMode: 3
20+
m_FogDensity: 0.01
21+
m_LinearFogStart: 0
22+
m_LinearFogEnd: 300
23+
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
24+
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
25+
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
26+
m_AmbientIntensity: 1
27+
m_AmbientMode: 0
28+
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
29+
m_HaloStrength: 0.5
30+
m_FlareStrength: 1
31+
m_FlareFadeSpeed: 3
32+
m_HaloTexture: {fileID: 0}
33+
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
34+
m_DefaultReflectionMode: 0
35+
m_DefaultReflectionResolution: 128
36+
m_ReflectionBounces: 1
37+
m_ReflectionIntensity: 1
38+
m_CustomReflection: {fileID: 0}
39+
m_Sun: {fileID: 0}
40+
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
41+
--- !u!157 &3
42+
LightmapSettings:
43+
m_ObjectHideFlags: 0
44+
serializedVersion: 7
45+
m_GIWorkflowMode: 1
46+
m_GISettings:
47+
serializedVersion: 2
48+
m_BounceScale: 1
49+
m_IndirectOutputScale: 1
50+
m_AlbedoBoost: 1
51+
m_TemporalCoherenceThreshold: 1
52+
m_EnvironmentLightingMode: 0
53+
m_EnableBakedLightmaps: 1
54+
m_EnableRealtimeLightmaps: 1
55+
m_LightmapEditorSettings:
56+
serializedVersion: 4
57+
m_Resolution: 2
58+
m_BakeResolution: 40
59+
m_TextureWidth: 1024
60+
m_TextureHeight: 1024
61+
m_AO: 0
62+
m_AOMaxDistance: 1
63+
m_CompAOExponent: 1
64+
m_CompAOExponentDirect: 0
65+
m_Padding: 2
66+
m_LightmapParameters: {fileID: 0}
67+
m_LightmapsBakeMode: 1
68+
m_TextureCompression: 1
69+
m_DirectLightInLightProbes: 1
70+
m_FinalGather: 0
71+
m_FinalGatherFiltering: 1
72+
m_FinalGatherRayCount: 256
73+
m_ReflectionCompression: 2
74+
m_LightingDataAsset: {fileID: 0}
75+
m_RuntimeCPUUsage: 25
76+
--- !u!196 &4
77+
NavMeshSettings:
78+
serializedVersion: 2
79+
m_ObjectHideFlags: 0
80+
m_BuildSettings:
81+
serializedVersion: 2
82+
agentRadius: 0.5
83+
agentHeight: 2
84+
agentSlope: 45
85+
agentClimb: 0.4
86+
ledgeDropHeight: 0
87+
maxJumpAcrossDistance: 0
88+
accuratePlacement: 0
89+
minRegionArea: 2
90+
cellSize: 0.16666667
91+
manualCellSize: 0
92+
m_NavMeshData: {fileID: 0}
93+
--- !u!1001 &406582863
94+
Prefab:
95+
m_ObjectHideFlags: 0
96+
serializedVersion: 2
97+
m_Modification:
98+
m_TransformParent: {fileID: 0}
99+
m_Modifications:
100+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
101+
propertyPath: m_LocalPosition.x
102+
value: 0
103+
objectReference: {fileID: 0}
104+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
105+
propertyPath: m_LocalPosition.y
106+
value: 0
107+
objectReference: {fileID: 0}
108+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
109+
propertyPath: m_LocalPosition.z
110+
value: 0
111+
objectReference: {fileID: 0}
112+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
113+
propertyPath: m_LocalRotation.x
114+
value: 0
115+
objectReference: {fileID: 0}
116+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
117+
propertyPath: m_LocalRotation.y
118+
value: 0
119+
objectReference: {fileID: 0}
120+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
121+
propertyPath: m_LocalRotation.z
122+
value: 0
123+
objectReference: {fileID: 0}
124+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
125+
propertyPath: m_LocalRotation.w
126+
value: 1
127+
objectReference: {fileID: 0}
128+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
129+
propertyPath: m_RootOrder
130+
value: 1
131+
objectReference: {fileID: 0}
132+
- target: {fileID: 114000012919351050, guid: 0b20469ea0c7b2945bc2a68947531ead,
133+
type: 2}
134+
propertyPath: KeywordsAndResponses.Array.data[0].Response.m_PersistentCalls.m_Calls.Array.data[0].m_Target
135+
value:
136+
objectReference: {fileID: 1948556036}
137+
- target: {fileID: 102000014138650206, guid: 0b20469ea0c7b2945bc2a68947531ead,
138+
type: 2}
139+
propertyPath: m_Text
140+
value: Scanning | Spatial Mapping
141+
objectReference: {fileID: 0}
142+
- target: {fileID: 114000012919351050, guid: 0b20469ea0c7b2945bc2a68947531ead,
143+
type: 2}
144+
propertyPath: KeywordsAndResponses.Array.data[0].Response.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_StringArgument
145+
value: SpatialMappingMesh
146+
objectReference: {fileID: 0}
147+
m_RemovedComponents: []
148+
m_ParentPrefab: {fileID: 100100000, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
149+
m_IsPrefabParent: 0
150+
--- !u!1001 &1495444468
151+
Prefab:
152+
m_ObjectHideFlags: 0
153+
serializedVersion: 2
154+
m_Modification:
155+
m_TransformParent: {fileID: 0}
156+
m_Modifications:
157+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
158+
propertyPath: m_LocalPosition.x
159+
value: 0
160+
objectReference: {fileID: 0}
161+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
162+
propertyPath: m_LocalPosition.y
163+
value: 0
164+
objectReference: {fileID: 0}
165+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
166+
propertyPath: m_LocalPosition.z
167+
value: 0
168+
objectReference: {fileID: 0}
169+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
170+
propertyPath: m_LocalRotation.x
171+
value: -0
172+
objectReference: {fileID: 0}
173+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
174+
propertyPath: m_LocalRotation.y
175+
value: -0
176+
objectReference: {fileID: 0}
177+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
178+
propertyPath: m_LocalRotation.z
179+
value: -0
180+
objectReference: {fileID: 0}
181+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
182+
propertyPath: m_LocalRotation.w
183+
value: 1
184+
objectReference: {fileID: 0}
185+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
186+
propertyPath: m_RootOrder
187+
value: 2
188+
objectReference: {fileID: 0}
189+
- target: {fileID: 114000012698980792, guid: 2ed75ffdf9031c94e8bce4b3d17b9928,
190+
type: 2}
191+
propertyPath: TrianglesPerCubicMeter
192+
value: 2000
193+
objectReference: {fileID: 0}
194+
m_RemovedComponents:
195+
- {fileID: 114000012149591842, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
196+
m_ParentPrefab: {fileID: 100100000, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
197+
m_IsPrefabParent: 0
198+
--- !u!1001 &1806518574
199+
Prefab:
200+
m_ObjectHideFlags: 0
201+
serializedVersion: 2
202+
m_Modification:
203+
m_TransformParent: {fileID: 0}
204+
m_Modifications:
205+
- target: {fileID: 402774, guid: b84b73491ac53a34095000876132a211, type: 2}
206+
propertyPath: m_LocalPosition.x
207+
value: 0
208+
objectReference: {fileID: 0}
209+
- target: {fileID: 402774, guid: b84b73491ac53a34095000876132a211, type: 2}
210+
propertyPath: m_LocalPosition.y
211+
value: 0
212+
objectReference: {fileID: 0}
213+
- target: {fileID: 402774, guid: b84b73491ac53a34095000876132a211, type: 2}
214+
propertyPath: m_LocalPosition.z
215+
value: 0
216+
objectReference: {fileID: 0}
217+
- target: {fileID: 402774, guid: b84b73491ac53a34095000876132a211, type: 2}
218+
propertyPath: m_LocalRotation.x
219+
value: 0
220+
objectReference: {fileID: 0}
221+
- target: {fileID: 402774, guid: b84b73491ac53a34095000876132a211, type: 2}
222+
propertyPath: m_LocalRotation.y
223+
value: 0
224+
objectReference: {fileID: 0}
225+
- target: {fileID: 402774, guid: b84b73491ac53a34095000876132a211, type: 2}
226+
propertyPath: m_LocalRotation.z
227+
value: 0
228+
objectReference: {fileID: 0}
229+
- target: {fileID: 402774, guid: b84b73491ac53a34095000876132a211, type: 2}
230+
propertyPath: m_LocalRotation.w
231+
value: 1
232+
objectReference: {fileID: 0}
233+
- target: {fileID: 402774, guid: b84b73491ac53a34095000876132a211, type: 2}
234+
propertyPath: m_RootOrder
235+
value: 0
236+
objectReference: {fileID: 0}
237+
m_RemovedComponents: []
238+
m_ParentPrefab: {fileID: 100100000, guid: b84b73491ac53a34095000876132a211, type: 2}
239+
m_IsPrefabParent: 0
240+
--- !u!1 &1948556033 stripped
241+
GameObject:
242+
m_PrefabParentObject: {fileID: 1000010302963436, guid: 2ed75ffdf9031c94e8bce4b3d17b9928,
243+
type: 2}
244+
m_PrefabInternal: {fileID: 1495444468}
245+
--- !u!114 &1948556034
246+
MonoBehaviour:
247+
m_ObjectHideFlags: 0
248+
m_PrefabParentObject: {fileID: 0}
249+
m_PrefabInternal: {fileID: 0}
250+
m_GameObject: {fileID: 1948556033}
251+
m_Enabled: 1
252+
m_EditorHideFlags: 0
253+
m_Script: {fileID: 11500000, guid: c96e5de2c5d6ff048a7008e554de2a56, type: 3}
254+
m_Name:
255+
m_EditorClassIdentifier:
256+
MeshFileName: SpatialMappingMesh
257+
LoadFileKey: 108
258+
SaveFileKey: 0
259+
--- !u!114 &1948556036 stripped
260+
MonoBehaviour:
261+
m_PrefabParentObject: {fileID: 114000012698980792, guid: 2ed75ffdf9031c94e8bce4b3d17b9928,
262+
type: 2}
263+
m_PrefabInternal: {fileID: 1495444468}
264+
m_Script: {fileID: 11500000, guid: b2a98b181acba5549af3d852c7664623, type: 3}

0 commit comments

Comments
 (0)