INxrGazePointer.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Copyright 2016 Nibiru. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. using UnityEngine;
  15. /// This script provides an interface for gaze based input pointers used with
  16. /// the GazeInputModule script.
  17. ///
  18. /// It provides methods called on gaze interaction with in-game objects and UI,
  19. /// trigger events, and 'BaseInputModule' class state changes.
  20. ///
  21. /// To have the methods called, an instance of this (implemented) class must be
  22. /// registered with the **GazeInputModule** script on 'OnEnable' by assigning
  23. /// itself to the **GazeInputModule.gazePointer** static member variable.
  24. /// A registered instance should also un-register itself at 'OnDisable' calls
  25. /// by setting the **GazeInputModule.gazePointer** static member variable
  26. /// to null.
  27. ///
  28. /// This class is expected to be inherited by pointers responding to the user's
  29. /// looking at objects in the scene by the movement of their head. For example,
  30. /// see the NxrReticle class.
  31. namespace Nxr.Internal
  32. {
  33. public interface INxrGazePointer
  34. {
  35. /// This is called when the 'BaseInputModule' system should be enabled.
  36. void OnGazeEnabled();
  37. /// This is called when the 'BaseInputModule' system should be disabled.
  38. void OnGazeDisabled();
  39. /// Called when the user is looking on a valid GameObject. This can be a 3D
  40. /// or UI element.
  41. ///
  42. /// The camera is the event camera, the target is the object
  43. /// the user is looking at, and the intersectionPosition is the intersection
  44. /// point of the ray sent from the camera on the object.
  45. void OnGazeStart(Camera camera, GameObject targetObject, Vector3 intersectionPosition,
  46. bool isInteractive);
  47. /// Called every frame the user is still looking at a valid GameObject. This
  48. /// can be a 3D or UI element.
  49. ///
  50. /// The camera is the event camera, the target is the object the user is
  51. /// looking at, and the intersectionPosition is the intersection point of the
  52. /// ray sent from the camera on the object.
  53. void OnGazeStay(Camera camera, GameObject targetObject, Vector3 intersectionPosition,
  54. bool isInteractive);
  55. /// Called when the user's look no longer intersects an object previously
  56. /// intersected with a ray projected from the camera.
  57. /// This is also called just before **OnGazeDisabled** and may have have any of
  58. /// the values set as **null**.
  59. ///
  60. /// The camera is the event camera and the target is the object the user
  61. /// previously looked at.
  62. void OnGazeExit(Camera camera, GameObject targetObject);
  63. /// Called when a trigger event is initiated. This is practically when
  64. /// the user begins pressing the trigger.
  65. void OnGazeTriggerStart(Camera camera);
  66. /// Called when trigger event is finished. This is practically when
  67. /// the user releases the trigger.
  68. void OnGazeTriggerEnd(Camera camera);
  69. /// Return the radius of the gaze pointer. This is used when searching for
  70. /// valid gaze targets. If a radius is 0, the NxrGaze will use a ray
  71. /// to find a valid gaze target. Otherwise it will use a SphereCast.
  72. /// The *innerRadius* is used for finding new targets while the *outerRadius*
  73. /// is used to see if you are still nearby the object currently looked at
  74. /// to avoid a flickering effect when just at the border of the intersection.
  75. void GetPointerRadius(out float innerRadius, out float outerRadius);
  76. void UpdateStatus();
  77. }
  78. }