NRTrackingDataProvider.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /****************************************************************************
  2. * Copyright 2019 Nreal Techonology Limited. All rights reserved.
  3. *
  4. * This file is part of NRSDK.
  5. *
  6. * https://www.nreal.ai/
  7. *
  8. *****************************************************************************/
  9. namespace NRKernal
  10. {
  11. using UnityEngine;
  12. public class NRTrackingDataProvider : ITrackingDataProvider
  13. {
  14. NativeHeadTracking m_NativeHeadTracking;
  15. NativeTracking m_NativeTracking;
  16. public NRTrackingDataProvider()
  17. {
  18. if (NRSessionManager.Instance.NativeAPI == null)
  19. {
  20. NRSessionManager.Instance.NativeAPI = new NativeInterface();
  21. }
  22. m_NativeHeadTracking = NRSessionManager.Instance.NativeAPI.NativeHeadTracking;
  23. m_NativeTracking = NRSessionManager.Instance.NativeAPI.NativeTracking;
  24. m_NativeTracking.Create();
  25. }
  26. public void Start()
  27. {
  28. m_NativeTracking.Start();
  29. m_NativeHeadTracking.Start();
  30. }
  31. public void Pause()
  32. {
  33. m_NativeTracking.Pause();
  34. }
  35. public void Recenter()
  36. {
  37. m_NativeTracking.Recenter();
  38. }
  39. public void Resume()
  40. {
  41. m_NativeTracking.Resume();
  42. }
  43. public void Stop()
  44. {
  45. m_NativeHeadTracking.Destroy();
  46. m_NativeTracking.Destroy();
  47. }
  48. public bool SwitchTrackingMode(TrackingMode mode)
  49. {
  50. return m_NativeTracking.SwitchTrackingMode(mode);
  51. }
  52. public bool GetFramePresentHeadPose(ref Pose pose, ref LostTrackingReason lostReason, ref ulong timestamp)
  53. {
  54. return m_NativeHeadTracking.GetFramePresentHeadPose(ref pose, ref lostReason, ref timestamp);
  55. }
  56. public bool GetHeadPose(ref Pose pose, ulong timestamp)
  57. {
  58. return m_NativeHeadTracking.GetHeadPose(ref pose, timestamp);
  59. }
  60. public bool InitTrackingMode(TrackingMode mode)
  61. {
  62. return m_NativeTracking.InitTrackingMode(mode);
  63. }
  64. public bool GetFramePresentTimeByCount(int count, ref ulong timestamp)
  65. {
  66. return m_NativeHeadTracking.GetFramePresentTimeByCount(count, ref timestamp);
  67. }
  68. public ulong GetHMDTimeNanos()
  69. {
  70. return m_NativeHeadTracking.GetHMDTimeNanos();
  71. }
  72. }
  73. }