diff options
Diffstat (limited to 'servers')
-rw-r--r-- | servers/arvr/arvr_script_interface.cpp | 136 | ||||
-rw-r--r-- | servers/arvr/arvr_script_interface.h | 52 | ||||
-rw-r--r-- | servers/register_server_types.cpp | 8 |
3 files changed, 0 insertions, 196 deletions
diff --git a/servers/arvr/arvr_script_interface.cpp b/servers/arvr/arvr_script_interface.cpp deleted file mode 100644 index 2755605a14..0000000000 --- a/servers/arvr/arvr_script_interface.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "arvr_script_interface.h" - -ARVRScriptInterface::ARVRScriptInterface() { - // testing - printf("Construct script interface"); -} - -ARVRScriptInterface::~ARVRScriptInterface() { - if (is_initialized()) { - uninitialize(); - }; - - // testing - printf("Destruct script interface"); -} - -StringName ARVRScriptInterface::get_name() const { - if (get_script_instance() && get_script_instance()->has_method("get_name")) { - return get_script_instance()->call("get_name"); - } else { - // just return something for now - return "ARVR Script interface"; - } -} - -int ARVRScriptInterface::get_capabilities() const { - ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_capabilities")), ARVRInterface::ARVR_NONE); - return get_script_instance()->call("get_capabilities"); -}; - -ARVRInterface::Tracking_status ARVRScriptInterface::get_tracking_status() const { - ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_tracking_status")), ARVRInterface::ARVR_NOT_TRACKING); - int status = get_script_instance()->call("get_tracking_status"); - return (ARVRInterface::Tracking_status)status; -} - -bool ARVRScriptInterface::get_anchor_detection_is_enabled() const { - ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_anchor_detection_is_enabled")), false); - return get_script_instance()->call("get_anchor_detection_is_enabled"); -}; - -void ARVRScriptInterface::set_anchor_detection_is_enabled(bool p_enable) { - ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("set_anchor_detection_is_enabled"))); - get_script_instance()->call("set_anchor_detection_is_enabled"); -}; - -bool ARVRScriptInterface::is_stereo() { - ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("is_stereo")), false); - return get_script_instance()->call("is_stereo"); -} - -bool ARVRScriptInterface::is_initialized() { - ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("is_initialized")), false); - return get_script_instance()->call("is_initialized"); -} - -bool ARVRScriptInterface::initialize() { - ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("initialize")), false); - return get_script_instance()->call("initialize"); -} - -void ARVRScriptInterface::uninitialize() { - ARVRServer *arvr_server = ARVRServer::get_singleton(); - if (arvr_server != NULL) { - // Whatever happens, make sure this is no longer our primary interface - arvr_server->clear_primary_interface_if(this); - } - - ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("uninitialize"))); - get_script_instance()->call("uninitialize"); -} - -Size2 ARVRScriptInterface::get_recommended_render_targetsize() { - ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_recommended_render_targetsize")), Size2()); - return get_script_instance()->call("get_recommended_render_targetsize"); -} - -Transform ARVRScriptInterface::get_transform_for_eye(Eyes p_eye, const Transform &p_cam_transform) { - ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_transform_for_eye")), Transform()); - return get_script_instance()->call("get_transform_for_eye", p_eye, p_cam_transform); -} - -// Suggestion from Reduz, as we can't return a CameraMatrix, return a PoolVector with our 16 floats -PoolVector<float> ARVRScriptInterface::_get_projection_for_eye(Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) { - ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("_get_projection_for_eye")), PoolVector<float>()); - return get_script_instance()->call("_get_projection_for_eye", p_eye, p_aspect, p_z_near, p_z_far); -} - -CameraMatrix ARVRScriptInterface::get_projection_for_eye(Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) { - CameraMatrix cm; - int i = 0; - int j = 0; - - PoolVector<float> cm_as_floats = _get_projection_for_eye(p_eye, p_aspect, p_z_near, p_z_far); - - for (int k = 0; k < cm_as_floats.size() && i < 4; k++) { - cm.matrix[i][j] = cm_as_floats[k]; - j++; - if (j == 4) { - j = 0; - i++; - }; - }; - - return cm; -} - -void ARVRScriptInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) { - ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("commit_for_eye"))); - get_script_instance()->call("commit_for_eye"); -} - -void ARVRScriptInterface::process() { - ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("process"))); - get_script_instance()->call("process"); -} - -void ARVRScriptInterface::_bind_methods() { - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "get_capabilities")); - - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "is_initialized")); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "initialize")); - ClassDB::add_virtual_method(get_class_static(), MethodInfo("uninitialize")); - - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "get_tracking_status")); - - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "get_anchor_detection_is_enabled")); - ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_anchor_detection_is_enabled", PropertyInfo(Variant::BOOL, "enabled"))); - - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "is_stereo")); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::VECTOR2, "get_recommended_render_targetsize")); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::TRANSFORM, "get_transform_for_eye", PropertyInfo(Variant::INT, "eye"), PropertyInfo(Variant::TRANSFORM, "cam_transform"))); - ClassDB::add_virtual_method(get_class_static(), MethodInfo("_get_projection_for_eye")); - ClassDB::add_virtual_method(get_class_static(), MethodInfo("commit_for_eye", PropertyInfo(Variant::INT, "eye"), PropertyInfo(Variant::_RID, "render_target"))); - ClassDB::add_virtual_method(get_class_static(), MethodInfo("process")); -} diff --git a/servers/arvr/arvr_script_interface.h b/servers/arvr/arvr_script_interface.h deleted file mode 100644 index b1393b4fdb..0000000000 --- a/servers/arvr/arvr_script_interface.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef SCRIPT_INTERFACE_H -#define SCRIPT_INTERFACE_H - -#include "arvr_interface.h" - -/** - @authors Hinsbart & Karroffel - - This subclass of our AR/VR interface forms a bridge to GDNative. -*/ - -class ARVRScriptInterface : public ARVRInterface { - GDCLASS(ARVRScriptInterface, ARVRInterface); - -protected: - static void _bind_methods(); - -public: - /** general interface information **/ - ARVRScriptInterface(); - ~ARVRScriptInterface(); - - virtual StringName get_name() const; - virtual int get_capabilities() const; - - virtual bool is_initialized(); - virtual bool initialize(); - virtual void uninitialize(); - - ARVRInterface::Tracking_status get_tracking_status() const; /* get the status of our current tracking */ - - /** specific to AR **/ - virtual bool get_anchor_detection_is_enabled() const; - virtual void set_anchor_detection_is_enabled(bool p_enable); - - /** rendering and internal **/ - virtual Size2 get_recommended_render_targetsize(); - virtual bool is_stereo(); - virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform); - - // we expose a PoolVector<float> version of this function to GDNative - PoolVector<float> _get_projection_for_eye(Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far); - - // and a CameraMatrix version to ARVRServer - virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far); - - virtual void commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect); - - virtual void process(); -}; - -#endif // SCRIPT_INTERFACE_H diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index 1aee2144aa..7a9328e30f 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -32,7 +32,6 @@ #include "arvr/arvr_interface.h" #include "arvr/arvr_positional_tracker.h" -#include "arvr/arvr_script_interface.h" #include "arvr_server.h" #include "audio/audio_effect.h" #include "audio/audio_stream.h" @@ -74,10 +73,8 @@ static void _debugger_get_resource_usage(List<ScriptDebuggerRemote::ResourceUsag } ShaderTypes *shader_types = NULL; -ARVRServer *arvr_server = NULL; void register_server_types() { - arvr_server = memnew(ARVRServer); ClassDB::register_virtual_class<VisualServer>(); ClassDB::register_class<AudioServer>(); @@ -95,7 +92,6 @@ void register_server_types() { ClassDB::register_virtual_class<ARVRInterface>(); ClassDB::register_class<ARVRPositionalTracker>(); - ClassDB::register_class<ARVRScriptInterface>(); ClassDB::register_virtual_class<AudioStream>(); ClassDB::register_virtual_class<AudioStreamPlayback>(); @@ -152,9 +148,5 @@ void register_server_types() { void unregister_server_types() { - //@TODO move this into iPhone/Android implementation? just have this here for testing... - // mobile_interface = NULL; - memdelete(shader_types); - memdelete(arvr_server); } |