Skip to content

Commit

Permalink
Spatial Mapping updates (issue #146)
Browse files Browse the repository at this point in the history
This commit addresses issue #146. The SpatialMappingComponent folder is
no longer needed in the HoloToolkit, because these components
(SpatialMappingRenderer and SpatialMappingCollider) are now built into
Unity. However, providing a basic sample scene is useful to show how to
use the components, so I moved the old test scene into the new
HoloToolit-Examples folder and updated it to use the new built-in Unity
components.
  • Loading branch information
angelaHillier committed Aug 1, 2016
1 parent 584b4fe commit 38b419c
Show file tree
Hide file tree
Showing 23 changed files with 78 additions and 1,134 deletions.

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.

Expand Up @@ -178,21 +178,22 @@ MonoBehaviour:
m_GameObject: {fileID: 387044609}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 53755a21bd4f3454981c6de4efdfec5d, type: 3}
m_Script: {fileID: 247442469, guid: f7b54ff4a43d4fcf81b4538b678e0bcc, type: 3}
m_Name:
m_EditorClassIdentifier:
FreezeMeshUpdates: 0
UseSphereBounds: 0
Extents: {x: 5, y: 5, z: 5}
SphereRadius: 10
_levelOfDetailSet: 1
_levelOfDetail: 2
TimeBetweenUpdates: 2.5
NumUpdatesBeforeRemoval: 10
MeshLayer:
m_SurfaceParent: {fileID: 387044609}
m_FreezeUpdates: 0
m_Volume: 1
m_SphereRadiusMeters: 2
m_BoxExtentsMeters: {x: 5, y: 5, z: 5}
m_LOD: 2
m_NumUpdatesBeforeRemoval: 10
m_SecondsBetweenUpdates: 2.5
m_Layer:
serializedVersion: 2
m_Bits: 0
PhysicMaterial: {fileID: 0}
m_Bits: 1
m_Material: {fileID: 0}
m_EnableCollisions: 1
--- !u!1 &428511244
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -285,20 +286,20 @@ MonoBehaviour:
m_GameObject: {fileID: 1783506190}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6ca2f6b8dee51ea4bb59100b8f16fc1f, type: 3}
m_Script: {fileID: -594688902, guid: f7b54ff4a43d4fcf81b4538b678e0bcc, type: 3}
m_Name:
m_EditorClassIdentifier:
FreezeMeshUpdates: 0
UseSphereBounds: 0
Extents: {x: 5, y: 5, z: 5}
SphereRadius: 10
_levelOfDetailSet: 1
_levelOfDetail: 1
TimeBetweenUpdates: 2.5
NumUpdatesBeforeRemoval: 10
_currentRenderingSetting: 1
_renderingMaterial: {fileID: 2100000, guid: d698790d3facd3d4289a13fa1243030a, type: 2}
_occlusionMaterial: {fileID: 2100000, guid: df172103f5fba4a4d8636aeca60cb0d7, type: 2}
m_SurfaceParent: {fileID: 0}
m_FreezeUpdates: 0
m_Volume: 1
m_SphereRadiusMeters: 2
m_BoxExtentsMeters: {x: 5, y: 5, z: 5}
m_LOD: 1
m_NumUpdatesBeforeRemoval: 10
m_SecondsBetweenUpdates: 2.5
m_CurrentRenderSetting: 2
m_CustomMaterial: {fileID: 15303, guid: 0000000000000000f000000000000000, type: 0}
m_OcclusionMaterial: {fileID: 15302, guid: 0000000000000000f000000000000000, type: 0}
--- !u!114 &1783506192
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -307,21 +308,22 @@ MonoBehaviour:
m_GameObject: {fileID: 1783506190}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 53755a21bd4f3454981c6de4efdfec5d, type: 3}
m_Script: {fileID: 247442469, guid: f7b54ff4a43d4fcf81b4538b678e0bcc, type: 3}
m_Name:
m_EditorClassIdentifier:
FreezeMeshUpdates: 0
UseSphereBounds: 1
Extents: {x: 10, y: 10, z: 10}
SphereRadius: 5
_levelOfDetailSet: 1
_levelOfDetail: 2
TimeBetweenUpdates: 2.5
NumUpdatesBeforeRemoval: 10
MeshLayer:
m_SurfaceParent: {fileID: 0}
m_FreezeUpdates: 0
m_Volume: 0
m_SphereRadiusMeters: 5
m_BoxExtentsMeters: {x: 4, y: 4, z: 4}
m_LOD: 2
m_NumUpdatesBeforeRemoval: 10
m_SecondsBetweenUpdates: 2.5
m_Layer:
serializedVersion: 2
m_Bits: 0
PhysicMaterial: {fileID: 0}
m_Bits: 1
m_Material: {fileID: 0}
m_EnableCollisions: 1
--- !u!81 &1783506193
AudioListener:
m_ObjectHideFlags: 0
Expand Down
24 changes: 24 additions & 0 deletions Assets/HoloToolkit-Examples/SpatialMappingComponent/README.md
@@ -0,0 +1,24 @@
# SpatialMappingComponent Example
This example shows how to use the built-in Unity components for spatial mapping: SpatialMappingRenderer and SpatialMappingCollider. It shows an example of a static play space which preserves physics around it (marked by a cube) while maintaining physics and wire frame rendering of Spatial Mapping around the camera.

Additionally, you can tap to drop a cube in front of the camera with a Rigidbody component to interact with physics. As you drop cubes, you will notice that only the cubes that are dropped within the static play space will maintain a connection with the floor. If you wander too far from the static play space, cubes dropped outside of the space will eventually fall through the floor and disappear as you walk away from them.

#### SpatialMappingCollider:
Use this component for performing physics collisions with the Spatial Mapping mesh.

The example scene contains two 'SpatialMappingCollider' components. One is attached to the MainCamera object, and the second is attached to the 'StaticPlaySpaceLocation' object. As the user moves around, they can perform an 'air tap' gesture to drop cubes on the floor.

#### SpatialMappingRenderer:
Use this component for rendering the Spatial Mapping mesh.

The example scene has a 'SpatialMappingRenderer' attached to the MainCamera object. As the user moves around, a wireframe mesh will appear wherever they go. The color of the mesh will change based on distance from user.

#### Design Considerations

1. If you want spatial mapping to work wherever the user travels, attach the components to the camera and the specified bounds will move with the user.
2. If you want collisions to continue working even after walking away, you may want to leave a second SpatialMappingCollider around the play space where collisions should continue.
3. If you want physics collisions and to render the Spatial Mapping mesh for an area, you should add both a SpatialMappingCollider and a SpatialMappingRenderer

Though all of the defaults are usable out of the box with no customization, you can also customize the component to your scenario. Through script, additions such as PlaneFinding.cs can also be used with these components.

These components by default implement caching of removed Spatial Mapping meshes such that removed meshes will still be present for at least 10 updates after they are actually removed. This number and the feature can be configured via script. This feature enables mesh a great distance from the user to not be removed as well as quick re-hydration of mesh only removed as a user moved away and back to a single location.

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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 38b419c

Please sign in to comment.