/****************************************************************************
* Copyright 2019 Nreal Techonology Limited. All rights reserved.
*
* This file is part of NRSDK.
*
* https://www.nreal.ai/
*
*****************************************************************************/
using System.Collections;
using UnityEngine;
namespace NRKernal.NRExamples
{
/// An ensure slam tracking mode.
public class EnsureSlamTrackingMode : MonoBehaviour
{
/// Type of the tracking.
[SerializeField]
private NRHMDPoseTracker.TrackingType m_TrackingType = NRHMDPoseTracker.TrackingType.Tracking6Dof;
/// Starts this object.
void Start()
{
StartCoroutine(EnsureTrackingType(m_TrackingType));
}
private IEnumerator EnsureTrackingType(NRHMDPoseTracker.TrackingType type)
{
WaitForEndOfFrame waitForEndOfFrame = new WaitForEndOfFrame();
if (m_TrackingType == NRHMDPoseTracker.TrackingType.Tracking0Dof && NRSessionManager.Instance.NRHMDPoseTracker.TrackingMode != m_TrackingType)
{
while (!NRSessionManager.Instance.NRHMDPoseTracker.ChangeTo0Dof(null))
{
yield return waitForEndOfFrame;
}
}
else if (m_TrackingType == NRHMDPoseTracker.TrackingType.Tracking0DofStable && NRSessionManager.Instance.NRHMDPoseTracker.TrackingMode != m_TrackingType)
{
while (!NRSessionManager.Instance.NRHMDPoseTracker.ChangeTo0DofStable(null))
{
yield return waitForEndOfFrame;
}
}
else if (m_TrackingType == NRHMDPoseTracker.TrackingType.Tracking3Dof && NRSessionManager.Instance.NRHMDPoseTracker.TrackingMode != m_TrackingType)
{
while (!NRSessionManager.Instance.NRHMDPoseTracker.ChangeTo3Dof(null))
{
yield return waitForEndOfFrame;
}
}
else if (m_TrackingType == NRHMDPoseTracker.TrackingType.Tracking6Dof && NRSessionManager.Instance.NRHMDPoseTracker.TrackingMode != m_TrackingType)
{
while (!NRSessionManager.Instance.NRHMDPoseTracker.ChangeTo6Dof(null))
{
yield return waitForEndOfFrame;
}
}
}
}
}