openxr_composition_layer.h 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**************************************************************************/
  2. /* openxr_composition_layer.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef OPENXR_COMPOSITION_LAYER_H
  31. #define OPENXR_COMPOSITION_LAYER_H
  32. #include <openxr/openxr.h>
  33. #include "scene/3d/node_3d.h"
  34. class MeshInstance3D;
  35. class Mesh;
  36. class OpenXRAPI;
  37. class OpenXRCompositionLayerExtension;
  38. class OpenXRViewportCompositionLayerProvider;
  39. class SubViewport;
  40. class OpenXRCompositionLayer : public Node3D {
  41. GDCLASS(OpenXRCompositionLayer, Node3D);
  42. SubViewport *layer_viewport = nullptr;
  43. MeshInstance3D *fallback = nullptr;
  44. bool should_update_fallback_mesh = false;
  45. Dictionary extension_property_values;
  46. void _create_fallback_node();
  47. void _reset_fallback_material();
  48. protected:
  49. OpenXRAPI *openxr_api = nullptr;
  50. OpenXRCompositionLayerExtension *composition_layer_extension = nullptr;
  51. OpenXRViewportCompositionLayerProvider *openxr_layer_provider = nullptr;
  52. static void _bind_methods();
  53. void _notification(int p_what);
  54. void _get_property_list(List<PropertyInfo> *p_property_list) const;
  55. bool _get(const StringName &p_property, Variant &r_value) const;
  56. bool _set(const StringName &p_property, const Variant &p_value);
  57. virtual void _on_openxr_session_begun();
  58. virtual void _on_openxr_session_stopping();
  59. virtual Ref<Mesh> _create_fallback_mesh() = 0;
  60. void update_fallback_mesh();
  61. static HashSet<SubViewport *> viewports_in_use;
  62. public:
  63. void set_layer_viewport(SubViewport *p_viewport);
  64. SubViewport *get_layer_viewport() const;
  65. void set_sort_order(int p_order);
  66. int get_sort_order() const;
  67. void set_alpha_blend(bool p_alpha_blend);
  68. bool get_alpha_blend() const;
  69. bool is_natively_supported() const;
  70. virtual PackedStringArray get_configuration_warnings() const override;
  71. virtual Vector2 intersects_ray(const Vector3 &p_origin, const Vector3 &p_direction) const;
  72. OpenXRCompositionLayer();
  73. ~OpenXRCompositionLayer();
  74. };
  75. #endif // OPENXR_COMPOSITION_LAYER_H