NREmulatorTrackingDataProvider.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. #if UNITY_EDITOR
  13. public class NREmulatorTrackingDataProvider : ITrackingDataProvider
  14. {
  15. private NREmulatorHeadPose m_NREmulatorHeadPose;
  16. public NREmulatorTrackingDataProvider() { }
  17. public void Start()
  18. {
  19. MainThreadDispather.QueueOnMainThread(() =>
  20. {
  21. if (!NREmulatorManager.Inited && !GameObject.Find("NREmulatorManager"))
  22. {
  23. NREmulatorManager.Inited = true;
  24. GameObject.Instantiate(Resources.Load("Prefabs/NREmulatorManager"));
  25. }
  26. if (!GameObject.Find("NREmulatorHeadPos"))
  27. {
  28. m_NREmulatorHeadPose = GameObject.Instantiate<NREmulatorHeadPose>(
  29. Resources.Load<NREmulatorHeadPose>("Prefabs/NREmulatorHeadPose")
  30. );
  31. }
  32. });
  33. }
  34. public void Pause() { }
  35. public void Resume() { }
  36. public void Stop() { }
  37. public bool GetFramePresentHeadPose(ref Pose pose, ref LostTrackingReason lostReason, ref ulong timestamp)
  38. {
  39. if (m_NREmulatorHeadPose == null)
  40. {
  41. return false;
  42. }
  43. pose = m_NREmulatorHeadPose.headPose;
  44. lostReason = LostTrackingReason.NONE;
  45. timestamp = NRTools.GetTimeStamp();
  46. return true;
  47. }
  48. public bool GetHeadPose(ref Pose pose, ulong timestamp)
  49. {
  50. if (m_NREmulatorHeadPose == null)
  51. {
  52. return false;
  53. }
  54. pose = m_NREmulatorHeadPose.headPose;
  55. return true;
  56. }
  57. public bool InitTrackingMode(TrackingMode mode)
  58. {
  59. return true;
  60. }
  61. public bool SwitchTrackingMode(TrackingMode mode)
  62. {
  63. return true;
  64. }
  65. public void Recenter() { }
  66. public bool GetFramePresentTimeByCount(int count, ref ulong timestamp)
  67. {
  68. timestamp = NRTools.GetTimeStamp();
  69. return true;
  70. }
  71. public ulong GetHMDTimeNanos()
  72. {
  73. return 0;
  74. }
  75. }
  76. #endif
  77. }