Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions OSVR-Unity/Assets/OSVRUnity/src/VREye.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class VREye : MonoBehaviour
[HideInInspector]
public Transform cachedTransform;
[HideInInspector]
public VRHead head;
[HideInInspector]
public K1RadialDistortion DistortionEffect
{
get
Expand Down Expand Up @@ -97,6 +99,10 @@ void Init()
{
clientKit = GameObject.FindObjectOfType<ClientKit>();
}
if (head == null)
{
gameObject.GetComponentInParent<VRHead>();
}
//cache:
cachedTransform = transform;

Expand Down Expand Up @@ -130,12 +136,16 @@ private void SetViewportRects()
}
}

//Called after a camera finishes rendering the scene.
//Called before a camera renders the scene.
//the goal here is to update the client often to make sure we have the most recent tracker data
//this helps reduce latency
void OnPostRender()
void OnPreRender()
{
clientKit.context.update();
if (head)
{
head.UpdatePose();
}
}
#endregion

Expand Down
10 changes: 10 additions & 0 deletions OSVR-Unity/Assets/OSVRUnity/src/VRHead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class VRHead : MonoBehaviour
private DeviceDescriptor _deviceDescriptor;
private DisplayInterface _displayInterface;
private bool _initDisplayInterface = false;
private PoseInterface _poseIf;
#endregion

#region Init
Expand All @@ -69,6 +70,7 @@ void Start()
}
*/
_displayInterface = GetComponent<DisplayInterface>();
_poseIf = GetComponent<PoseInterface>();

//update VRHead with info from the display interface if it has been initialized
//it might not be initialized if it is still parsing a display json file
Expand Down Expand Up @@ -103,6 +105,12 @@ void Update()
UpdateViewMode();
}
}
public void UpdatePose()
{
var state = _poseIf.Interface.GetState();
transform.localPosition = state.Value.Position;
transform.localRotation = state.Value.Rotation;
}
#endregion

#region Public Methods
Expand Down Expand Up @@ -165,6 +173,8 @@ void CatalogEyes()
switch (currentEye.eye)
{
case Eye.left:
// Only need one eye to update the head.
currentEye.head = this;
_leftEye = currentEye;
break;

Expand Down