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.

96 lines
3.5 KiB

  1. // Simulator Boundaries|SDK_Simulator|004
  2. namespace VRTK
  3. {
  4. using UnityEngine;
  5. /// <summary>
  6. /// The Sim Boundaries SDK script provides dummy functions for the play area boundaries.
  7. /// </summary>
  8. [SDK_Description(typeof(SDK_SimSystem))]
  9. public class SDK_SimBoundaries : SDK_BaseBoundaries
  10. {
  11. private Transform area;
  12. /// <summary>
  13. /// The InitBoundaries method is run on start of scene and can be used to initialse anything on game start.
  14. /// </summary>
  15. public override void InitBoundaries()
  16. {
  17. }
  18. /// <summary>
  19. /// The GetPlayArea method returns the Transform of the object that is used to represent the play area in the scene.
  20. /// </summary>
  21. /// <returns>A transform of the object representing the play area in the scene.</returns>
  22. public override Transform GetPlayArea()
  23. {
  24. if (area == null)
  25. {
  26. GameObject simPlayer = SDK_InputSimulator.FindInScene();
  27. if (simPlayer)
  28. {
  29. area = simPlayer.transform;
  30. }
  31. }
  32. return area;
  33. }
  34. /// <summary>
  35. /// The GetPlayAreaVertices method returns the points of the play area boundaries.
  36. /// </summary>
  37. /// <returns>A Vector3 array of the points in the scene that represent the play area boundaries.</returns>
  38. public override Vector3[] GetPlayAreaVertices()
  39. {
  40. float inner = 0.9f;
  41. float outer = 1f;
  42. Vector3[] vertices = new Vector3[8];
  43. vertices[0] = new Vector3(inner, 0f, -inner);
  44. vertices[1] = new Vector3(-inner, 0f, -inner);
  45. vertices[2] = new Vector3(-inner, 0f, inner);
  46. vertices[3] = new Vector3(inner, 0f, inner);
  47. vertices[4] = new Vector3(outer, 0f, -outer);
  48. vertices[5] = new Vector3(-outer, 0f, -outer);
  49. vertices[6] = new Vector3(-outer, 0f, outer);
  50. vertices[7] = new Vector3(outer, 0f, outer);
  51. return vertices;
  52. }
  53. /// <summary>
  54. /// The GetPlayAreaBorderThickness returns the thickness of the drawn border for the given play area.
  55. /// </summary>
  56. /// <returns>The thickness of the drawn border.</returns>
  57. public override float GetPlayAreaBorderThickness()
  58. {
  59. return 0.1f;
  60. }
  61. /// <summary>
  62. /// The IsPlayAreaSizeCalibrated method returns whether the given play area size has been auto calibrated by external sensors.
  63. /// </summary>
  64. /// <returns>Returns true if the play area size has been auto calibrated and set by external sensors.</returns>
  65. public override bool IsPlayAreaSizeCalibrated()
  66. {
  67. return true;
  68. }
  69. /// <summary>
  70. /// The GetDrawAtRuntime method returns whether the given play area drawn border is being displayed.
  71. /// </summary>
  72. /// <returns>Returns true if the drawn border is being displayed.</returns>
  73. public override bool GetDrawAtRuntime()
  74. {
  75. return false;
  76. }
  77. /// <summary>
  78. /// The SetDrawAtRuntime method sets whether the given play area drawn border should be displayed at runtime.
  79. /// </summary>
  80. /// <param name="value">The state of whether the drawn border should be displayed or not.</param>
  81. public override void SetDrawAtRuntime(bool value)
  82. {
  83. }
  84. }
  85. }