ControllerAnchorsHelper.cs 4.0 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. /// <summary> Values that represent controller anchor enums. </summary>
  13. public enum ControllerAnchorEnum
  14. {
  15. /// <summary> An enum constant representing the gaze pose tracker anchor option. </summary>
  16. GazePoseTrackerAnchor,
  17. /// <summary> An enum constant representing the right pose tracker anchor option. </summary>
  18. RightPoseTrackerAnchor,
  19. /// <summary> An enum constant representing the left pose tracker anchor option. </summary>
  20. LeftPoseTrackerAnchor,
  21. /// <summary> An enum constant representing the right model anchor option. </summary>
  22. RightModelAnchor,
  23. /// <summary> An enum constant representing the left model anchor option. </summary>
  24. LeftModelAnchor,
  25. /// <summary> An enum constant representing the right laser anchor option. </summary>
  26. RightLaserAnchor,
  27. /// <summary> An enum constant representing the left laser anchor option. </summary>
  28. LeftLaserAnchor
  29. }
  30. /// <summary>
  31. /// The class is for user to easily get the transform of common controller anchors. </summary>
  32. [HelpURL("https://developer.nreal.ai/develop/unity/controller")]
  33. public class ControllerAnchorsHelper : MonoBehaviour
  34. {
  35. /// <summary> The gaze pose tracker anchor. </summary>
  36. [SerializeField]
  37. private Transform m_GazePoseTrackerAnchor;
  38. /// <summary> The right pose tracker anchor. </summary>
  39. [SerializeField]
  40. private Transform m_RightPoseTrackerAnchor;
  41. /// <summary> The left pose tracker anchor. </summary>
  42. [SerializeField]
  43. private Transform m_LeftPoseTrackerAnchor;
  44. /// <summary> The right model anchor. </summary>
  45. [SerializeField]
  46. private Transform m_RightModelAnchor;
  47. /// <summary> The left model anchor. </summary>
  48. [SerializeField]
  49. private Transform m_LeftModelAnchor;
  50. /// <summary> The right laser anchor. </summary>
  51. [SerializeField]
  52. private Transform m_RightLaserAnchor;
  53. /// <summary> The left laser anchor. </summary>
  54. [SerializeField]
  55. private Transform m_LeftLaserAnchor;
  56. /// <summary> Gets an anchor. </summary>
  57. /// <param name="anchorEnum"> The anchor enum.</param>
  58. /// <returns> The anchor. </returns>
  59. public Transform GetAnchor(ControllerAnchorEnum anchorEnum)
  60. {
  61. switch (anchorEnum)
  62. {
  63. case ControllerAnchorEnum.GazePoseTrackerAnchor:
  64. return m_GazePoseTrackerAnchor;
  65. case ControllerAnchorEnum.RightPoseTrackerAnchor:
  66. return m_RightPoseTrackerAnchor;
  67. case ControllerAnchorEnum.LeftPoseTrackerAnchor:
  68. return m_LeftPoseTrackerAnchor;
  69. case ControllerAnchorEnum.RightModelAnchor:
  70. return m_RightModelAnchor;
  71. case ControllerAnchorEnum.LeftModelAnchor:
  72. return m_LeftModelAnchor;
  73. case ControllerAnchorEnum.RightLaserAnchor:
  74. return m_RightLaserAnchor;
  75. case ControllerAnchorEnum.LeftLaserAnchor:
  76. return m_LeftLaserAnchor;
  77. default:
  78. break;
  79. }
  80. return null;
  81. }
  82. }
  83. }