File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
OSVR-Unity/Assets/OSVRUnity/src Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ public class VREye : MonoBehaviour
46
46
[ HideInInspector ]
47
47
public Transform cachedTransform ;
48
48
[ HideInInspector ]
49
+ public VRHead head ;
50
+ [ HideInInspector ]
49
51
public K1RadialDistortion DistortionEffect
50
52
{
51
53
get
@@ -97,6 +99,10 @@ void Init()
97
99
{
98
100
clientKit = GameObject . FindObjectOfType < ClientKit > ( ) ;
99
101
}
102
+ if ( head == null )
103
+ {
104
+ gameObject . GetComponentInParent < VRHead > ( ) ;
105
+ }
100
106
//cache:
101
107
cachedTransform = transform ;
102
108
@@ -130,12 +136,16 @@ private void SetViewportRects()
130
136
}
131
137
}
132
138
133
- //Called after a camera finishes rendering the scene.
139
+ //Called before a camera renders the scene.
134
140
//the goal here is to update the client often to make sure we have the most recent tracker data
135
141
//this helps reduce latency
136
- void OnPostRender ( )
142
+ void OnPreRender ( )
137
143
{
138
144
clientKit . context . update ( ) ;
145
+ if ( head )
146
+ {
147
+ head . UpdatePose ( ) ;
148
+ }
139
149
}
140
150
#endregion
141
151
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ public class VRHead : MonoBehaviour
55
55
private DeviceDescriptor _deviceDescriptor ;
56
56
private DisplayInterface _displayInterface ;
57
57
private bool _initDisplayInterface = false ;
58
+ private PoseInterface _poseIf ;
58
59
#endregion
59
60
60
61
#region Init
@@ -69,6 +70,7 @@ void Start()
69
70
}
70
71
*/
71
72
_displayInterface = GetComponent < DisplayInterface > ( ) ;
73
+ _poseIf = GetComponent < PoseInterface > ( ) ;
72
74
73
75
//update VRHead with info from the display interface if it has been initialized
74
76
//it might not be initialized if it is still parsing a display json file
@@ -103,6 +105,12 @@ void Update()
103
105
UpdateViewMode ( ) ;
104
106
}
105
107
}
108
+ public void UpdatePose ( )
109
+ {
110
+ var state = _poseIf . Interface . GetState ( ) ;
111
+ transform . localPosition = state . Value . Position ;
112
+ transform . localRotation = state . Value . Rotation ;
113
+ }
106
114
#endregion
107
115
108
116
#region Public Methods
@@ -165,6 +173,8 @@ void CatalogEyes()
165
173
switch ( currentEye . eye )
166
174
{
167
175
case Eye . left :
176
+ // Only need one eye to update the head.
177
+ currentEye . head = this ;
168
178
_leftEye = currentEye ;
169
179
break ;
170
180
You can’t perform that action at this time.
0 commit comments