Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
3.6 KiB

  1. // Ximmerse Boundaries|SDK_Ximmerse|005
  2. namespace VRTK
  3. {
  4. #if VRTK_DEFINE_SDK_XIMMERSE
  5. using UnityEngine;
  6. using Ximmerse.VR;
  7. #endif
  8. /// <summary>
  9. /// The Ximmerse Boundaries SDK script provides a bridge to the Ximmerse SDK play area.
  10. /// </summary>
  11. [SDK_Description(typeof(SDK_XimmerseSystem))]
  12. [SDK_Description(typeof(SDK_XimmerseSystem), 1)]
  13. public class SDK_XimmerseBoundaries
  14. #if VRTK_DEFINE_SDK_XIMMERSE
  15. : SDK_BaseBoundaries
  16. #else
  17. : SDK_FallbackBoundaries
  18. #endif
  19. {
  20. #if VRTK_DEFINE_SDK_XIMMERSE
  21. /// <summary>
  22. /// The InitBoundaries method is run on start of scene and can be used to initialse anything on game start.
  23. /// </summary>
  24. public override void InitBoundaries()
  25. {
  26. }
  27. /// <summary>
  28. /// The GetPlayArea method returns the Transform of the object that is used to represent the play area in the scene.
  29. /// </summary>
  30. /// <returns>A transform of the object representing the play area in the scene.</returns>
  31. public override Transform GetPlayArea()
  32. {
  33. cachedPlayArea = GetSDKManagerPlayArea();
  34. if (cachedPlayArea == null)
  35. {
  36. VRContext vrContext = VRTK_SharedMethods.FindEvenInactiveComponent<VRContext>(true);
  37. if (Application.isPlaying)
  38. {
  39. vrContext.InitVRContext();
  40. }
  41. cachedPlayArea = vrContext.transform;
  42. }
  43. return cachedPlayArea;
  44. }
  45. /// <summary>
  46. /// The GetPlayAreaVertices method returns the points of the play area boundaries.
  47. /// </summary>
  48. /// <returns>A Vector3 array of the points in the scene that represent the play area boundaries.</returns>
  49. public override Vector3[] GetPlayAreaVertices()
  50. {
  51. var area = GetPlayArea().GetComponentInChildren<PlayAreaRenderer>();
  52. if (area)
  53. {
  54. return area.corners;
  55. }
  56. return null;
  57. }
  58. /// <summary>
  59. /// The GetPlayAreaBorderThickness returns the thickness of the drawn border for the given play area.
  60. /// </summary>
  61. /// <returns>The thickness of the drawn border.</returns>
  62. public override float GetPlayAreaBorderThickness()
  63. {
  64. var area = GetPlayArea().GetComponentInChildren<PlayAreaRenderer>();
  65. if (area)
  66. {
  67. return area.borderThickness;
  68. }
  69. return 0f;
  70. }
  71. /// <summary>
  72. /// The IsPlayAreaSizeCalibrated method returns whether the given play area size has been auto calibrated by external sensors.
  73. /// </summary>
  74. /// <returns>Returns true if the play area size has been auto calibrated and set by external sensors.</returns>
  75. public override bool IsPlayAreaSizeCalibrated()
  76. {
  77. return true;
  78. }
  79. /// <summary>
  80. /// The GetDrawAtRuntime method returns whether the given play area drawn border is being displayed.
  81. /// </summary>
  82. /// <returns>Returns true if the drawn border is being displayed.</returns>
  83. public override bool GetDrawAtRuntime()
  84. {
  85. return false;
  86. }
  87. /// <summary>
  88. /// The SetDrawAtRuntime method sets whether the given play area drawn border should be displayed at runtime.
  89. /// </summary>
  90. /// <param name="value">The state of whether the drawn border should be displayed or not.</param>
  91. public override void SetDrawAtRuntime(bool value)
  92. {
  93. }
  94. #endif
  95. }
  96. }