arvr_interface_gdnative.h 3.8 KB

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