xr_interface_gdnative.h 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*************************************************************************/
  2. /* xr_interface_gdnative.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  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 XR_INTERFACE_GDNATIVE_H
  31. #define XR_INTERFACE_GDNATIVE_H
  32. #include "modules/gdnative/gdnative.h"
  33. #include "servers/xr/xr_interface.h"
  34. /**
  35. @authors Hinsbart & Karroffel & Mux213
  36. This subclass of our AR/VR interface forms a bridge to GDNative.
  37. */
  38. class XRInterfaceGDNative : public XRInterface {
  39. GDCLASS(XRInterfaceGDNative, XRInterface);
  40. void cleanup();
  41. protected:
  42. const godot_xr_interface_gdnative *interface;
  43. void *data;
  44. static void _bind_methods();
  45. public:
  46. /** general interface information **/
  47. XRInterfaceGDNative();
  48. ~XRInterfaceGDNative();
  49. void set_interface(const godot_xr_interface_gdnative *p_interface);
  50. virtual StringName get_name() const override;
  51. virtual int get_capabilities() const override;
  52. virtual bool is_initialized() const override;
  53. virtual bool initialize() override;
  54. virtual void uninitialize() override;
  55. /** specific to AR **/
  56. virtual bool get_anchor_detection_is_enabled() const override;
  57. virtual void set_anchor_detection_is_enabled(bool p_enable) override;
  58. virtual int get_camera_feed_id() override;
  59. /** rendering and internal **/
  60. virtual Size2 get_render_targetsize() override;
  61. virtual bool is_stereo() override;
  62. virtual Transform get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform) override;
  63. // we expose a Vector<float> version of this function to GDNative
  64. Vector<float> _get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
  65. // and a CameraMatrix version to XRServer
  66. virtual CameraMatrix get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) override;
  67. virtual unsigned int get_external_texture_for_eye(XRInterface::Eyes p_eye) override;
  68. virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) override;
  69. virtual void process() override;
  70. virtual void notification(int p_what) override;
  71. };
  72. #endif // XR_INTERFACE_GDNATIVE_H