Skip to content

Commit 7e0a68a

Browse files
authored
Merge pull request #9 from jbienzms/feature/BetterRecording
Feature Better Recording
2 parents 9621521 + d311c6b commit 7e0a68a

File tree

14 files changed

+287
-85
lines changed

14 files changed

+287
-85
lines changed
147 KB
Loading
160 KB
Loading
201 KB
Loading
114 KB
Loading
212 KB
Loading

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Spatial Alignment for Unity
2+
This reference architecture includes many helpful components for aligning and keeping virtual objects aligned with the physical world.
3+
4+
### Release 1.0
5+
Release 1.0 contains the following capabilities:
6+
7+
##### Spatial Frames
8+
*Spatial Frames* represent "islands" in the real world. They have a position and a rotation and are designed to hold objects. They also have unique IDs and can be available from the moment the application loads (even before they're found in the real world). This simplifies application logic because objects can be loaded up front and automatically aligned when the frame is found.
9+
10+
![](External/ReadMeImages/Align-FramesAndStrategies.png)
11+
12+
##### Alignment Strategies
13+
Each *Spatial Frame* has an *Alignment Strategy*. The strategy is what moves the frame and keeps it aligned in the physical world. Alignment Strategies are "plugins", and developers can easily create their own strategies. Applications are free to mix and match various strategies in the same application.
14+
15+
![](External/ReadMeImages/Align-MixStrategies.png)
16+
17+
Alignment Strategies provide information about their state (e.g. whether they've been found) and their accuracy (maximum drift in meters). Applications can then use this information to make intelligent decisions about the best frames to use contain objects. In fact, one of the included strategies is a *Multi-Parent* strategy that allows objects to automatically "hop" parent frames based on their state and accuracy.
18+
19+
![](External/ReadMeImages/Align-ParentHopping.png)
20+
21+
##### Refinement
22+
Two of the greatest challenges with spatial alignment are:
23+
24+
1. Initial placement (and rotation) of objects to match up with the physical world
25+
2. Accounting for drift that accumulates over distance (a challenge that is present in all large-scale tracking systems)
26+
27+
This reference architecture includes components to help address both. To help with accurate alignment, an extensible system of *Refinement Controllers* is provided. In version 1.0 there is one refinement controller included called **RayRefinement**. **RayRefinement** allows a virtual model and a physical space to be aligned by selecting the corresponding origin points and a direction.
28+
29+
30+
**TODO: RayRefinement Video**
31+
32+
33+
34+
35+
##### Persistence
36+
37+
38+
##### Examples
39+
40+
41+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
42+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

SpatialAlignment-Unity/Assets/SpatialAlignment-Examples/Refinement/Models/Room/Room_LOD1/Materials/Room.mat

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ Material:
99
m_PrefabAsset: {fileID: 0}
1010
m_Name: Room
1111
m_Shader: {fileID: 4800000, guid: d45c0efca53019e43891b0f610f8146e, type: 3}
12-
m_ShaderKeywords: _BORDER_LIGHT_USES_HOVER_COLOR _HOVER_LIGHT _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
12+
m_ShaderKeywords: _ALPHATEST_ON _BORDER_LIGHT_USES_HOVER_COLOR _HOVER_LIGHT _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
1313
_SPECULAR_HIGHLIGHTS
1414
m_LightmapFlags: 4
1515
m_EnableInstancingVariants: 0
1616
m_DoubleSidedGI: 0
17-
m_CustomRenderQueue: 2000
17+
m_CustomRenderQueue: 2450
1818
stringTagMap:
19-
RenderType: Opaque
19+
RenderType: TransparentCutout
2020
disabledShaderPasses: []
2121
m_SavedProperties:
2222
serializedVersion: 3
@@ -75,7 +75,7 @@ Material:
7575
- _ClippingPlaneBorderWidth: 0.025
7676
- _ColorWriteMask: 15
7777
- _CullMode: 2
78-
- _CustomMode: 0
78+
- _CustomMode: 1
7979
- _Cutoff: 0.5
8080
- _DetailNormalMapScale: 1
8181
- _DirectionalLight: 0
@@ -97,7 +97,7 @@ Material:
9797
- _HoverLightOpaque: 0
9898
- _InnerGlow: 0
9999
- _Metallic: 0
100-
- _Mode: 0
100+
- _Mode: 1
101101
- _NearPlaneFade: 0
102102
- _OcclusionStrength: 1
103103
- _Parallax: 0.02

SpatialAlignment-Unity/Assets/SpatialAlignment-Examples/Refinement/Scenes/SA-RefinementBuilding.unity

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,75 @@ NavMeshSettings:
112112
debug:
113113
m_Flags: 0
114114
m_NavMeshData: {fileID: 0}
115+
--- !u!1001 &90715524
116+
PrefabInstance:
117+
m_ObjectHideFlags: 0
118+
serializedVersion: 2
119+
m_Modification:
120+
m_TransformParent: {fileID: 1746543277}
121+
m_Modifications:
122+
- target: {fileID: 188249851610165992, guid: 5bb225293e05e5846823a417d4471bc6,
123+
type: 3}
124+
propertyPath: m_Name
125+
value: SplitView
126+
objectReference: {fileID: 0}
127+
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
128+
type: 3}
129+
propertyPath: m_LocalPosition.x
130+
value: 0
131+
objectReference: {fileID: 0}
132+
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
133+
type: 3}
134+
propertyPath: m_LocalPosition.y
135+
value: 0
136+
objectReference: {fileID: 0}
137+
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
138+
type: 3}
139+
propertyPath: m_LocalPosition.z
140+
value: 0.86
141+
objectReference: {fileID: 0}
142+
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
143+
type: 3}
144+
propertyPath: m_LocalRotation.x
145+
value: -0
146+
objectReference: {fileID: 0}
147+
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
148+
type: 3}
149+
propertyPath: m_LocalRotation.y
150+
value: -0
151+
objectReference: {fileID: 0}
152+
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
153+
type: 3}
154+
propertyPath: m_LocalRotation.z
155+
value: -0
156+
objectReference: {fileID: 0}
157+
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
158+
type: 3}
159+
propertyPath: m_LocalRotation.w
160+
value: 1
161+
objectReference: {fileID: 0}
162+
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
163+
type: 3}
164+
propertyPath: m_RootOrder
165+
value: 2
166+
objectReference: {fileID: 0}
167+
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
168+
type: 3}
169+
propertyPath: m_LocalEulerAnglesHint.x
170+
value: 0
171+
objectReference: {fileID: 0}
172+
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
173+
type: 3}
174+
propertyPath: m_LocalEulerAnglesHint.y
175+
value: 0
176+
objectReference: {fileID: 0}
177+
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
178+
type: 3}
179+
propertyPath: m_LocalEulerAnglesHint.z
180+
value: 0
181+
objectReference: {fileID: 0}
182+
m_RemovedComponents: []
183+
m_SourcePrefab: {fileID: 100100000, guid: 5bb225293e05e5846823a417d4471bc6, type: 3}
115184
--- !u!1 &97103547
116185
GameObject:
117186
m_ObjectHideFlags: 0
@@ -417,7 +486,7 @@ GameObject:
417486
m_Icon: {fileID: 0}
418487
m_NavMeshLayer: 0
419488
m_StaticEditorFlags: 0
420-
m_IsActive: 1
489+
m_IsActive: 0
421490
--- !u!4 &332004588
422491
Transform:
423492
m_ObjectHideFlags: 0
@@ -742,7 +811,7 @@ GameObject:
742811
m_Icon: {fileID: 0}
743812
m_NavMeshLayer: 0
744813
m_StaticEditorFlags: 0
745-
m_IsActive: 1
814+
m_IsActive: 0
746815
--- !u!4 &1478666015
747816
Transform:
748817
m_ObjectHideFlags: 0
@@ -966,7 +1035,7 @@ GameObject:
9661035
m_Icon: {fileID: 0}
9671036
m_NavMeshLayer: 0
9681037
m_StaticEditorFlags: 0
969-
m_IsActive: 1
1038+
m_IsActive: 0
9701039
--- !u!4 &1891623027
9711040
Transform:
9721041
m_ObjectHideFlags: 0
@@ -1100,75 +1169,6 @@ MeshFilter:
11001169
m_PrefabAsset: {fileID: 0}
11011170
m_GameObject: {fileID: 2059821774}
11021171
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
1103-
--- !u!1001 &188249851934458066
1104-
PrefabInstance:
1105-
m_ObjectHideFlags: 0
1106-
serializedVersion: 2
1107-
m_Modification:
1108-
m_TransformParent: {fileID: 1746543277}
1109-
m_Modifications:
1110-
- target: {fileID: 188249851610165992, guid: 5bb225293e05e5846823a417d4471bc6,
1111-
type: 3}
1112-
propertyPath: m_Name
1113-
value: SplitView
1114-
objectReference: {fileID: 0}
1115-
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
1116-
type: 3}
1117-
propertyPath: m_LocalPosition.x
1118-
value: 0
1119-
objectReference: {fileID: 0}
1120-
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
1121-
type: 3}
1122-
propertyPath: m_LocalPosition.y
1123-
value: 0
1124-
objectReference: {fileID: 0}
1125-
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
1126-
type: 3}
1127-
propertyPath: m_LocalPosition.z
1128-
value: 0.31
1129-
objectReference: {fileID: 0}
1130-
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
1131-
type: 3}
1132-
propertyPath: m_LocalRotation.x
1133-
value: -0
1134-
objectReference: {fileID: 0}
1135-
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
1136-
type: 3}
1137-
propertyPath: m_LocalRotation.y
1138-
value: -0
1139-
objectReference: {fileID: 0}
1140-
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
1141-
type: 3}
1142-
propertyPath: m_LocalRotation.z
1143-
value: -0
1144-
objectReference: {fileID: 0}
1145-
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
1146-
type: 3}
1147-
propertyPath: m_LocalRotation.w
1148-
value: 1
1149-
objectReference: {fileID: 0}
1150-
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
1151-
type: 3}
1152-
propertyPath: m_RootOrder
1153-
value: 2
1154-
objectReference: {fileID: 0}
1155-
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
1156-
type: 3}
1157-
propertyPath: m_LocalEulerAnglesHint.x
1158-
value: 0
1159-
objectReference: {fileID: 0}
1160-
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
1161-
type: 3}
1162-
propertyPath: m_LocalEulerAnglesHint.y
1163-
value: 0
1164-
objectReference: {fileID: 0}
1165-
- target: {fileID: 188249851610165993, guid: 5bb225293e05e5846823a417d4471bc6,
1166-
type: 3}
1167-
propertyPath: m_LocalEulerAnglesHint.z
1168-
value: 0
1169-
objectReference: {fileID: 0}
1170-
m_RemovedComponents: []
1171-
m_SourcePrefab: {fileID: 100100000, guid: 5bb225293e05e5846823a417d4471bc6, type: 3}
11721172
--- !u!1001 &1633407210776251376
11731173
PrefabInstance:
11741174
m_ObjectHideFlags: 0

SpatialAlignment-Unity/Assets/SpatialAlignment/Refinement/Scripts/RayRefinement.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,16 @@ protected virtual void OnInputClicked(InputClickedEventData eventData)
357357
/// <inheritdoc />
358358
protected override void OnRefinementCanceled()
359359
{
360+
// Re-show meshes?
361+
if (autoHideMeshes)
362+
{
363+
this.gameObject.SetMeshesEnabled(enabled: true, inChildren: true);
364+
}
365+
366+
// Cleanup resources
360367
StopAndCleanup();
368+
369+
// Pass to base to finish
361370
base.OnRefinementCanceled();
362371
}
363372

SpatialAlignment-Unity/Assets/SpatialAlignment/Utilities/Materials.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.

0 commit comments

Comments
 (0)