Skip to content

Commit 77235f0

Browse files
author
Stephen Hodgson
authored
Merge pull request #289 from Ziugy/dev/protoKitBacklog
Saving Spatial Mapping & Understanding Meshes
2 parents 0f236fa + 13f0905 commit 77235f0

22 files changed

+1419
-9
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 Name] > 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: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!29 &1
4+
OcclusionCullingSettings:
5+
m_ObjectHideFlags: 0
6+
serializedVersion: 2
7+
m_OcclusionBakeSettings:
8+
smallestOccluder: 5
9+
smallestHole: 0.25
10+
backfaceThreshold: 100
11+
m_SceneGUID: 00000000000000000000000000000000
12+
m_OcclusionCullingData: {fileID: 0}
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+
agentTypeID: 0
83+
agentRadius: 0.5
84+
agentHeight: 2
85+
agentSlope: 45
86+
agentClimb: 0.4
87+
ledgeDropHeight: 0
88+
maxJumpAcrossDistance: 0
89+
minRegionArea: 2
90+
manualCellSize: 0
91+
cellSize: 0.16666667
92+
accuratePlacement: 0
93+
m_NavMeshData: {fileID: 0}
94+
--- !u!1001 &213568931
95+
Prefab:
96+
m_ObjectHideFlags: 0
97+
serializedVersion: 2
98+
m_Modification:
99+
m_TransformParent: {fileID: 0}
100+
m_Modifications:
101+
- target: {fileID: 4000010560871102, guid: d379ed0a5618c9f479f58bd83a2d0ad3, type: 2}
102+
propertyPath: m_LocalPosition.x
103+
value: 0
104+
objectReference: {fileID: 0}
105+
- target: {fileID: 4000010560871102, guid: d379ed0a5618c9f479f58bd83a2d0ad3, type: 2}
106+
propertyPath: m_LocalPosition.y
107+
value: 0
108+
objectReference: {fileID: 0}
109+
- target: {fileID: 4000010560871102, guid: d379ed0a5618c9f479f58bd83a2d0ad3, type: 2}
110+
propertyPath: m_LocalPosition.z
111+
value: 0
112+
objectReference: {fileID: 0}
113+
- target: {fileID: 4000010560871102, guid: d379ed0a5618c9f479f58bd83a2d0ad3, type: 2}
114+
propertyPath: m_LocalRotation.x
115+
value: 0
116+
objectReference: {fileID: 0}
117+
- target: {fileID: 4000010560871102, guid: d379ed0a5618c9f479f58bd83a2d0ad3, type: 2}
118+
propertyPath: m_LocalRotation.y
119+
value: 0
120+
objectReference: {fileID: 0}
121+
- target: {fileID: 4000010560871102, guid: d379ed0a5618c9f479f58bd83a2d0ad3, type: 2}
122+
propertyPath: m_LocalRotation.z
123+
value: 0
124+
objectReference: {fileID: 0}
125+
- target: {fileID: 4000010560871102, guid: d379ed0a5618c9f479f58bd83a2d0ad3, type: 2}
126+
propertyPath: m_LocalRotation.w
127+
value: 1
128+
objectReference: {fileID: 0}
129+
- target: {fileID: 4000010560871102, guid: d379ed0a5618c9f479f58bd83a2d0ad3, type: 2}
130+
propertyPath: m_RootOrder
131+
value: 0
132+
objectReference: {fileID: 0}
133+
m_RemovedComponents: []
134+
m_ParentPrefab: {fileID: 100100000, guid: d379ed0a5618c9f479f58bd83a2d0ad3, type: 2}
135+
m_IsPrefabParent: 0
136+
--- !u!1001 &406582863
137+
Prefab:
138+
m_ObjectHideFlags: 0
139+
serializedVersion: 2
140+
m_Modification:
141+
m_TransformParent: {fileID: 0}
142+
m_Modifications:
143+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
144+
propertyPath: m_LocalPosition.x
145+
value: 0
146+
objectReference: {fileID: 0}
147+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
148+
propertyPath: m_LocalPosition.y
149+
value: 0
150+
objectReference: {fileID: 0}
151+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
152+
propertyPath: m_LocalPosition.z
153+
value: 0
154+
objectReference: {fileID: 0}
155+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
156+
propertyPath: m_LocalRotation.x
157+
value: 0
158+
objectReference: {fileID: 0}
159+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
160+
propertyPath: m_LocalRotation.y
161+
value: 0
162+
objectReference: {fileID: 0}
163+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
164+
propertyPath: m_LocalRotation.z
165+
value: 0
166+
objectReference: {fileID: 0}
167+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
168+
propertyPath: m_LocalRotation.w
169+
value: 1
170+
objectReference: {fileID: 0}
171+
- target: {fileID: 4000013862256140, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
172+
propertyPath: m_RootOrder
173+
value: 1
174+
objectReference: {fileID: 0}
175+
- target: {fileID: 114000012919351050, guid: 0b20469ea0c7b2945bc2a68947531ead,
176+
type: 2}
177+
propertyPath: KeywordsAndResponses.Array.data[0].Response.m_PersistentCalls.m_Calls.Array.data[0].m_Target
178+
value:
179+
objectReference: {fileID: 1948556036}
180+
- target: {fileID: 102000014138650206, guid: 0b20469ea0c7b2945bc2a68947531ead,
181+
type: 2}
182+
propertyPath: m_Text
183+
value: Scanning | Spatial Mapping
184+
objectReference: {fileID: 0}
185+
- target: {fileID: 114000012919351050, guid: 0b20469ea0c7b2945bc2a68947531ead,
186+
type: 2}
187+
propertyPath: KeywordsAndResponses.Array.data[0].Response.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_StringArgument
188+
value: SpatialMappingMesh
189+
objectReference: {fileID: 0}
190+
m_RemovedComponents: []
191+
m_ParentPrefab: {fileID: 100100000, guid: 0b20469ea0c7b2945bc2a68947531ead, type: 2}
192+
m_IsPrefabParent: 0
193+
--- !u!1001 &1495444468
194+
Prefab:
195+
m_ObjectHideFlags: 0
196+
serializedVersion: 2
197+
m_Modification:
198+
m_TransformParent: {fileID: 0}
199+
m_Modifications:
200+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
201+
propertyPath: m_LocalPosition.x
202+
value: 0
203+
objectReference: {fileID: 0}
204+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
205+
propertyPath: m_LocalPosition.y
206+
value: 0
207+
objectReference: {fileID: 0}
208+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
209+
propertyPath: m_LocalPosition.z
210+
value: 0
211+
objectReference: {fileID: 0}
212+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
213+
propertyPath: m_LocalRotation.x
214+
value: -0
215+
objectReference: {fileID: 0}
216+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
217+
propertyPath: m_LocalRotation.y
218+
value: -0
219+
objectReference: {fileID: 0}
220+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
221+
propertyPath: m_LocalRotation.z
222+
value: -0
223+
objectReference: {fileID: 0}
224+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
225+
propertyPath: m_LocalRotation.w
226+
value: 1
227+
objectReference: {fileID: 0}
228+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
229+
propertyPath: m_RootOrder
230+
value: 2
231+
objectReference: {fileID: 0}
232+
- target: {fileID: 114000012698980792, guid: 2ed75ffdf9031c94e8bce4b3d17b9928,
233+
type: 2}
234+
propertyPath: TrianglesPerCubicMeter
235+
value: 2000
236+
objectReference: {fileID: 0}
237+
m_RemovedComponents:
238+
- {fileID: 114000012149591842, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
239+
m_ParentPrefab: {fileID: 100100000, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
240+
m_IsPrefabParent: 0
241+
--- !u!1 &1948556033 stripped
242+
GameObject:
243+
m_PrefabParentObject: {fileID: 1000010302963436, guid: 2ed75ffdf9031c94e8bce4b3d17b9928,
244+
type: 2}
245+
m_PrefabInternal: {fileID: 1495444468}
246+
--- !u!114 &1948556034
247+
MonoBehaviour:
248+
m_ObjectHideFlags: 0
249+
m_PrefabParentObject: {fileID: 0}
250+
m_PrefabInternal: {fileID: 0}
251+
m_GameObject: {fileID: 1948556033}
252+
m_Enabled: 1
253+
m_EditorHideFlags: 0
254+
m_Script: {fileID: 11500000, guid: c96e5de2c5d6ff048a7008e554de2a56, type: 3}
255+
m_Name:
256+
m_EditorClassIdentifier:
257+
MeshFileName: SpatialMappingMesh
258+
LoadFileKey: 108
259+
SaveFileKey: 0
260+
--- !u!114 &1948556036 stripped
261+
MonoBehaviour:
262+
m_PrefabParentObject: {fileID: 114000012698980792, guid: 2ed75ffdf9031c94e8bce4b3d17b9928,
263+
type: 2}
264+
m_PrefabInternal: {fileID: 1495444468}
265+
m_Script: {fileID: 11500000, guid: b2a98b181acba5549af3d852c7664623, type: 3}

0 commit comments

Comments
 (0)