Skip to content

Commit

Permalink
Spatial Mapping Updates
Browse files Browse the repository at this point in the history
Commits which address issues microsoft#144, microsoft#143, and microsoft#39. These commits include
the following changes:
1) Add the ObjectSurfaceObserver for loading meshes from a room file to
the SpatialMapping prefab (replaces the old FileSurfaceObserver).
2) Moves the FileSurfaceObserver onto the RemoteMapping prefab, for
saving/loading files from a remote mapping session.
3) Move all scripts related to RemoteMapping into a separate folder.
4) Move all scripts related to Processing into a separate folder.
5) Remove RemoteMapping prefab from the SpatialProcessing.unity test
scene. SpatialProcessing test will now load a .obj file when running in
Unity.
6) Add a RemoteMapping.unity test scene to help test the RemoteMapping
scripts.
7) Update documentation.
8) Remove Plugins\WSA\x64\PlaneFinding.dll which was failing WACK and is
not actually used by anything.
  • Loading branch information
angelaHillier committed Aug 3, 2016
1 parent c5630c4 commit 9acc20a
Show file tree
Hide file tree
Showing 41 changed files with 383 additions and 162 deletions.
Binary file not shown.

This file was deleted.

14 changes: 14 additions & 0 deletions Assets/HoloToolkit/SpatialMapping/Prefabs/RemoteMapping.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ GameObject:
- 114: {fileID: 114000013950815180}
- 114: {fileID: 114000010791004466}
- 114: {fileID: 114000012256053342}
- 114: {fileID: 114000013862356290}
m_Layer: 0
m_Name: RemoteMapping
m_TagString: Untagged
Expand All @@ -41,6 +42,7 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &114000010791004466
MonoBehaviour:
m_ObjectHideFlags: 1
Expand All @@ -65,6 +67,18 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e0e40e7a40c41984bbec8aaa64292522, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &114000013862356290
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012046505862}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c96e5de2c5d6ff048a7008e554de2a56, type: 3}
m_Name:
m_EditorClassIdentifier:
MeshFileName: roombackup
--- !u!114 &114000013950815180
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down
10 changes: 6 additions & 4 deletions Assets/HoloToolkit/SpatialMapping/Prefabs/SpatialMapping.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ GameObject:
- 4: {fileID: 4000013298573622}
- 114: {fileID: 114000012698980792}
- 114: {fileID: 114000011154029958}
- 114: {fileID: 114000012459388718}
- 114: {fileID: 114000012149591842}
m_Layer: 0
m_Name: SpatialMapping
m_TagString: Untagged
Expand All @@ -41,6 +41,7 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &114000011154029958
MonoBehaviour:
m_ObjectHideFlags: 1
Expand All @@ -54,20 +55,21 @@ MonoBehaviour:
m_EditorClassIdentifier:
PhysicsLayer: 31
surfaceMaterial: {fileID: 2100000, guid: d698790d3facd3d4289a13fa1243030a, type: 2}
autoStartObserver: 1
drawVisualMeshes: 1
castShadows: 0
--- !u!114 &114000012459388718
--- !u!114 &114000012149591842
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010302963436}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c96e5de2c5d6ff048a7008e554de2a56, type: 3}
m_Script: {fileID: 11500000, guid: 13d883c0118351e4890753200e0ac916, type: 3}
m_Name:
m_EditorClassIdentifier:
MeshFileName: roombackup
roomModel: {fileID: 0}
--- !u!114 &114000012698980792
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ public class FileSurfaceObserver : SpatialMappingSource
[Tooltip("The file name to use when saving and loading meshes.")]
public string MeshFileName = "roombackup";

[Tooltip("Key to press in editor to load a spatial mapping mesh from a .room file.")]
public KeyCode LoadFileKey = KeyCode.L;

[Tooltip("Key to press in editor to save a spatial mapping mesh to file.")]
public KeyCode SaveFileKey = KeyCode.S;

/// <summary>
/// Loads the SpatialMapping mesh from the specified file.
/// </summary>
Expand Down Expand Up @@ -59,5 +65,25 @@ public void Load(string fileName)
Debug.Log("Failed to load " + fileName);
}
}

// Called every frame.
private void Update()
{
// Keyboard commands for saving and loading a remotely generated mesh file.
#if UNITY_EDITOR
// S - saves the active mesh
if (Input.GetKeyUp(KeyCode.S))
{
MeshSaver.Save(MeshFileName, SpatialMappingManager.Instance.GetMeshes());
}

// L - loads the previously saved mesh into editor and sets it to be the spatial mapping source.
if (Input.GetKeyUp(KeyCode.L))
{
SpatialMappingManager.Instance.SetSpatialMappingSource(this);
Load(MeshFileName);
}
#endif
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ namespace HoloToolkit.Unity
[RequireComponent(typeof(RemoteMeshTarget))]
public partial class RemoteMappingManager : Singleton<RemoteMappingManager>
{
[Tooltip("Key to press in editor to enable spatial mapping over the network.")]
public KeyCode RemoteMappingKey = KeyCode.N;

[Tooltip("Keyword for sending meshes from HoloLens to Unity over the network.")]
public string SendMeshesKeyword = "send meshes";

/// <summary>
/// Receives meshes collected over the network.
/// </summary>
Expand All @@ -31,7 +37,7 @@ private void Start()
{
// Create our keyword collection.
keywordCollection = new Dictionary<string, System.Action>();
keywordCollection.Add("send meshes", () => SendMeshes());
keywordCollection.Add(SendMeshesKeyword, () => SendMeshes());

// Tell the KeywordRecognizer about our keywords.
keywordRecognizer = new KeywordRecognizer(keywordCollection.Keys.ToArray());
Expand All @@ -55,8 +61,8 @@ private void Start()
private void Update()
{
#if UNITY_EDITOR
// N - To use the 'network' sourced mesh.
if (Input.GetKeyUp(KeyCode.N))
// Use the 'network' sourced mesh.
if (Input.GetKeyUp(RemoteMappingKey))
{
SpatialMappingManager.Instance.SetSpatialMappingSource(remoteMeshTarget);
}
Expand Down
54 changes: 0 additions & 54 deletions Assets/HoloToolkit/SpatialMapping/Scripts/SpatialMappingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ public partial class SpatialMappingManager : Singleton<SpatialMappingManager>
/// </summary>
private SpatialMappingObserver surfaceObserver;

/// <summary>
/// Used for loading or saving spatial mapping data to disk.
/// </summary>
private FileSurfaceObserver fileSurfaceObserver;

/// <summary>
/// Used for sending meshes over the network and saving them to disk.
/// </summary>
private RemoteMeshTarget remoteMeshTarget;

/// <summary>
/// Time when StartObserver() was called.
/// </summary>
Expand All @@ -66,39 +56,12 @@ private void Awake()
// Use for initialization.
private void Start()
{
remoteMeshTarget = FindObjectOfType<RemoteMeshTarget>();

if (autoStartObserver)
{
StartObserver();
}
}

// Called every frame.
private void Update()
{
// There are a few keyboard commands we will add when in the editor.
#if UNITY_EDITOR
// F - to use the 'file' sourced mesh.
if (Input.GetKeyUp(KeyCode.F))
{
SpatialMappingManager.Instance.SetSpatialMappingSource(fileSurfaceObserver);
}

// S - saves the active mesh
if (Input.GetKeyUp(KeyCode.S))
{
MeshSaver.Save(fileSurfaceObserver.MeshFileName, SpatialMappingManager.Instance.GetMeshes());
}

// L - loads the previously saved mesh into the file source.
if (Input.GetKeyUp(KeyCode.L))
{
fileSurfaceObserver.Load(fileSurfaceObserver.MeshFileName);
}
#endif
}

/// <summary>
/// Returns the layer as a bit mask.
/// </summary>
Expand Down Expand Up @@ -223,23 +186,6 @@ public void StartObserver()
surfaceObserver.StartObserving();
StartTime = Time.time;
}
#elif UNITY_EDITOR
fileSurfaceObserver = GetComponent<FileSurfaceObserver>();

if (fileSurfaceObserver != null)
{
// In the Unity editor, try loading a saved mesh.
fileSurfaceObserver.Load(fileSurfaceObserver.MeshFileName);

if (fileSurfaceObserver.GetMeshFilters().Count > 0)
{
SetSpatialMappingSource(fileSurfaceObserver);
}
else if (remoteMeshTarget != null)
{
SetSpatialMappingSource(remoteMeshTarget);
}
}
#endif
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9acc20a

Please sign in to comment.