Debian Codegraph @

servers/xr/xr_interface_extension.h

raw symbols SCIP
1 /**************************************************************************/
2 /* xr_interface_extension.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
31 #pragma once
32
33 #include "servers/xr/xr_interface.h"
34
35 class XRInterfaceExtension : public XRInterface {
36 GDCLASS(XRInterfaceExtension, XRInterface);
37
38 public:
39 private:
40 bool can_add_blits = false;
41 Vector<BlitToScreen> blits;
42
43 protected:
44 _THREAD_SAFE_CLASS_
45
46 static void _bind_methods();
47
48 public:
49 /** general interface information **/
50 virtual StringName get_name() const override;
51 virtual uint32_t get_capabilities() const override;
52
53 GDVIRTUAL0RC(StringName, _get_name);
54 GDVIRTUAL0RC(uint32_t, _get_capabilities);
55
56 virtual bool is_initialized() const override;
57 virtual bool initialize() override;
58 virtual void uninitialize() override;
59 virtual Dictionary get_system_info() override;
60
61 GDVIRTUAL0RC(bool, _is_initialized);
62 GDVIRTUAL0R(bool, _initialize);
63 GDVIRTUAL0(_uninitialize);
64 GDVIRTUAL0RC(Dictionary, _get_system_info);
65
66 /** input and output **/
67
68 virtual PackedStringArray get_suggested_tracker_names() const override; /* return a list of likely/suggested tracker names */
69 virtual PackedStringArray get_suggested_pose_names(const StringName &p_tracker_name) const override; /* return a list of likely/suggested action names for this tracker */
70 virtual TrackingStatus get_tracking_status() const override;
71 virtual void trigger_haptic_pulse(const String &p_action_name, const StringName &p_tracker_name, double p_frequency, double p_amplitude, double p_duration_sec, double p_delay_sec = 0) override;
72
73 GDVIRTUAL0RC(PackedStringArray, _get_suggested_tracker_names);
74 GDVIRTUAL1RC(PackedStringArray, _get_suggested_pose_names, const StringName &);
75 GDVIRTUAL0RC(XRInterface::TrackingStatus, _get_tracking_status);
76 GDVIRTUAL6(_trigger_haptic_pulse, const String &, const StringName &, double, double, double, double);
77
78 /** specific to VR **/
79 virtual bool supports_play_area_mode(XRInterface::PlayAreaMode p_mode) override; /* query if this interface supports this play area mode */
80 virtual XRInterface::PlayAreaMode get_play_area_mode() const override; /* get the current play area mode */
81 virtual bool set_play_area_mode(XRInterface::PlayAreaMode p_mode) override; /* change the play area mode, note that this should return false if the mode is not available */
82 virtual PackedVector3Array get_play_area() const override; /* if available, returns an array of vectors denoting the play area the player can move around in */
83
84 GDVIRTUAL1RC(bool, _supports_play_area_mode, XRInterface::PlayAreaMode);
85 GDVIRTUAL0RC(XRInterface::PlayAreaMode, _get_play_area_mode);
86 GDVIRTUAL1RC(bool, _set_play_area_mode, XRInterface::PlayAreaMode);
87 GDVIRTUAL0RC(PackedVector3Array, _get_play_area);
88
89 /** specific to AR **/
90 virtual bool get_anchor_detection_is_enabled() const override;
91 virtual void set_anchor_detection_is_enabled(bool p_enable) override;
92 virtual int get_camera_feed_id() override;
93
94 GDVIRTUAL0RC(bool, _get_anchor_detection_is_enabled);
95 GDVIRTUAL1(_set_anchor_detection_is_enabled, bool);
96 GDVIRTUAL0RC(int, _get_camera_feed_id);
97
98 /** rendering and internal **/
99
100 virtual Size2 get_render_target_size() override;
101 virtual uint32_t get_view_count() override;
102 virtual Transform3D get_camera_transform() override;
103 virtual Transform3D get_transform_for_view(uint32_t p_view, const Transform3D &p_cam_transform) override;
104 virtual Projection get_projection_for_view(uint32_t p_view, double p_aspect, double p_z_near, double p_z_far) override;
105 virtual RID get_vrs_texture() override;
106 virtual VRSTextureFormat get_vrs_texture_format() override;
107 virtual RID get_color_texture() override;
108 virtual RID get_depth_texture() override;
109 virtual RID get_velocity_texture() override;
110
111 GDVIRTUAL0R(Size2, _get_render_target_size);
112 GDVIRTUAL0R(uint32_t, _get_view_count);
113 GDVIRTUAL0R(Transform3D, _get_camera_transform);
114 GDVIRTUAL2R(Transform3D, _get_transform_for_view, uint32_t, const Transform3D &);
115 GDVIRTUAL4R(PackedFloat64Array, _get_projection_for_view, uint32_t, double, double, double);
116 GDVIRTUAL0R(RID, _get_vrs_texture);
117 GDVIRTUAL0R(VRSTextureFormat, _get_vrs_texture_format);
118 GDVIRTUAL0R(RID, _get_color_texture);
119 GDVIRTUAL0R(RID, _get_depth_texture);
120 GDVIRTUAL0R(RID, _get_velocity_texture);
121
122 void add_blit(RID p_render_target, Rect2 p_src_rect, Rect2i p_dst_rect, bool p_use_layer = false, uint32_t p_layer = 0, bool p_apply_lens_distortion = false, Vector2 p_eye_center = Vector2(), double p_k1 = 0.0, double p_k2 = 0.0, double p_upscale = 1.0, double p_aspect_ratio = 1.0);
123
124 virtual void process() override;
125 virtual void pre_render() override;
126 virtual bool pre_draw_viewport(RID p_render_target) override;
127 virtual Vector<BlitToScreen> post_draw_viewport(RID p_render_target, const Rect2 &p_screen_rect) override;
128 virtual void end_frame() override;
129
130 GDVIRTUAL0(_process);
131 GDVIRTUAL0(_pre_render);
132 GDVIRTUAL1R(bool, _pre_draw_viewport, RID);
133 GDVIRTUAL2(_post_draw_viewport, RID, const Rect2 &);
134 GDVIRTUAL0(_end_frame);
135
136 /* access to some internals we need */
137 RID get_render_target_texture(RID p_render_target);
138 // RID get_render_target_depth(RID p_render_target);
139 };