Path: blob/master/servers/xr/xr_interface_extension.h
10277 views
/**************************************************************************/1/* xr_interface_extension.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "servers/xr/xr_interface.h"3334class XRInterfaceExtension : public XRInterface {35GDCLASS(XRInterfaceExtension, XRInterface);3637public:38private:39bool can_add_blits = false;40Vector<BlitToScreen> blits;4142protected:43_THREAD_SAFE_CLASS_4445static void _bind_methods();4647public:48/** general interface information **/49virtual StringName get_name() const override;50virtual uint32_t get_capabilities() const override;5152GDVIRTUAL0RC(StringName, _get_name);53GDVIRTUAL0RC(uint32_t, _get_capabilities);5455virtual bool is_initialized() const override;56virtual bool initialize() override;57virtual void uninitialize() override;58virtual Dictionary get_system_info() override;5960GDVIRTUAL0RC(bool, _is_initialized);61GDVIRTUAL0R(bool, _initialize);62GDVIRTUAL0(_uninitialize);63GDVIRTUAL0RC(Dictionary, _get_system_info);6465/** input and output **/6667virtual PackedStringArray get_suggested_tracker_names() const override; /* return a list of likely/suggested tracker names */68virtual PackedStringArray get_suggested_pose_names(const StringName &p_tracker_name) const override; /* return a list of likely/suggested action names for this tracker */69virtual TrackingStatus get_tracking_status() const override;70virtual 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;7172GDVIRTUAL0RC(PackedStringArray, _get_suggested_tracker_names);73GDVIRTUAL1RC(PackedStringArray, _get_suggested_pose_names, const StringName &);74GDVIRTUAL0RC(XRInterface::TrackingStatus, _get_tracking_status);75GDVIRTUAL6(_trigger_haptic_pulse, const String &, const StringName &, double, double, double, double);7677/** specific to VR **/78virtual bool supports_play_area_mode(XRInterface::PlayAreaMode p_mode) override; /* query if this interface supports this play area mode */79virtual XRInterface::PlayAreaMode get_play_area_mode() const override; /* get the current play area mode */80virtual 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 */81virtual PackedVector3Array get_play_area() const override; /* if available, returns an array of vectors denoting the play area the player can move around in */8283GDVIRTUAL1RC(bool, _supports_play_area_mode, XRInterface::PlayAreaMode);84GDVIRTUAL0RC(XRInterface::PlayAreaMode, _get_play_area_mode);85GDVIRTUAL1RC(bool, _set_play_area_mode, XRInterface::PlayAreaMode);86GDVIRTUAL0RC(PackedVector3Array, _get_play_area);8788/** specific to AR **/89virtual bool get_anchor_detection_is_enabled() const override;90virtual void set_anchor_detection_is_enabled(bool p_enable) override;91virtual int get_camera_feed_id() override;9293GDVIRTUAL0RC(bool, _get_anchor_detection_is_enabled);94GDVIRTUAL1(_set_anchor_detection_is_enabled, bool);95GDVIRTUAL0RC(int, _get_camera_feed_id);9697/** rendering and internal **/9899virtual Size2 get_render_target_size() override;100virtual uint32_t get_view_count() override;101virtual Transform3D get_camera_transform() override;102virtual Transform3D get_transform_for_view(uint32_t p_view, const Transform3D &p_cam_transform) override;103virtual Projection get_projection_for_view(uint32_t p_view, double p_aspect, double p_z_near, double p_z_far) override;104virtual RID get_vrs_texture() override;105virtual VRSTextureFormat get_vrs_texture_format() override;106virtual RID get_color_texture() override;107virtual RID get_depth_texture() override;108virtual RID get_velocity_texture() override;109110GDVIRTUAL0R(Size2, _get_render_target_size);111GDVIRTUAL0R(uint32_t, _get_view_count);112GDVIRTUAL0R(Transform3D, _get_camera_transform);113GDVIRTUAL2R(Transform3D, _get_transform_for_view, uint32_t, const Transform3D &);114GDVIRTUAL4R(PackedFloat64Array, _get_projection_for_view, uint32_t, double, double, double);115GDVIRTUAL0R(RID, _get_vrs_texture);116GDVIRTUAL0R(VRSTextureFormat, _get_vrs_texture_format);117GDVIRTUAL0R(RID, _get_color_texture);118GDVIRTUAL0R(RID, _get_depth_texture);119GDVIRTUAL0R(RID, _get_velocity_texture);120121void 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);122123virtual void process() override;124virtual void pre_render() override;125virtual bool pre_draw_viewport(RID p_render_target) override;126virtual Vector<BlitToScreen> post_draw_viewport(RID p_render_target, const Rect2 &p_screen_rect) override;127virtual void end_frame() override;128129GDVIRTUAL0(_process);130GDVIRTUAL0(_pre_render);131GDVIRTUAL1R(bool, _pre_draw_viewport, RID);132GDVIRTUAL2(_post_draw_viewport, RID, const Rect2 &);133GDVIRTUAL0(_end_frame);134135/* access to some internals we need */136RID get_render_target_texture(RID p_render_target);137// RID get_render_target_depth(RID p_render_target);138};139140141