diff options
author | BastiaanOlij <mux213@gmail.com> | 2017-09-29 21:36:27 +1000 |
---|---|---|
committer | BastiaanOlij <mux213@gmail.com> | 2017-10-06 20:35:55 +1100 |
commit | ce74efacbbad6edc7d84975f4480aa254f73b6cd (patch) | |
tree | ab4021340116ceb85a24a76f0f6134c9c81bf987 /modules | |
parent | ba2c49531d23093cbc46bb390d58cf1e60bf79d0 (diff) |
Made a few tweaks to the interface
Diffstat (limited to 'modules')
-rw-r--r-- | modules/mobile_vr/config.py | 8 | ||||
-rw-r--r-- | modules/mobile_vr/doc_classes/MobileVRInterface.xml | 134 | ||||
-rw-r--r-- | modules/mobile_vr/mobile_interface.cpp | 29 | ||||
-rw-r--r-- | modules/mobile_vr/mobile_interface.h | 5 |
4 files changed, 153 insertions, 23 deletions
diff --git a/modules/mobile_vr/config.py b/modules/mobile_vr/config.py index d0156b1b77..cf96c66125 100644 --- a/modules/mobile_vr/config.py +++ b/modules/mobile_vr/config.py @@ -3,4 +3,10 @@ def can_build(platform): return True def configure(env): - pass
\ No newline at end of file + pass + +def get_doc_classes(): + return ["MobileVRInterface"] + +def get_doc_path(): + return "doc_classes" diff --git a/modules/mobile_vr/doc_classes/MobileVRInterface.xml b/modules/mobile_vr/doc_classes/MobileVRInterface.xml new file mode 100644 index 0000000000..c945a99a9a --- /dev/null +++ b/modules/mobile_vr/doc_classes/MobileVRInterface.xml @@ -0,0 +1,134 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="MobileVRInterface" inherits="ARVRInterface" category="Core" version="3.0.alpha.custom_build"> + <brief_description> + Generic mobile VR implementation + </brief_description> + <description> + This is a generic mobile VR implementation where you need to provide details about the phone and HMD used. It does not rely on any existing framework. This is the most basic interface we have. For the best effect you do need a mobile phone with a gyroscope and accelerometer. + Note that even though there is no positional tracking the camera will assume the headset is at a height of 1.85 meters. + </description> + <tutorials> + </tutorials> + <demos> + </demos> + <methods> + <method name="get_display_to_lens" qualifiers="const"> + <return type="float"> + </return> + <description> + Returns the distance between the display and the lens. + </description> + </method> + <method name="get_display_width" qualifiers="const"> + <return type="float"> + </return> + <description> + Return the width of the LCD screen of the device. + </description> + </method> + <method name="get_iod" qualifiers="const"> + <return type="float"> + </return> + <description> + Returns the interocular distance. + </description> + </method> + <method name="get_k1" qualifiers="const"> + <return type="float"> + </return> + <description> + Returns the k1 lens constant. + </description> + </method> + <method name="get_k2" qualifiers="const"> + <return type="float"> + </return> + <description> + Retuns the k2 lens constant + </description> + </method> + <method name="get_oversample" qualifiers="const"> + <return type="float"> + </return> + <description> + Returns the oversampling setting. + </description> + </method> + <method name="set_display_to_lens"> + <return type="void"> + </return> + <argument index="0" name="display_to_lens" type="float"> + </argument> + <description> + Sets the distance between display and the lens. + </description> + </method> + <method name="set_display_width"> + <return type="void"> + </return> + <argument index="0" name="display_width" type="float"> + </argument> + <description> + Sets the width of the LCD screen of the device. + </description> + </method> + <method name="set_iod"> + <return type="void"> + </return> + <argument index="0" name="iod" type="float"> + </argument> + <description> + Sets the interocular distance. + </description> + </method> + <method name="set_k1"> + <return type="void"> + </return> + <argument index="0" name="k" type="float"> + </argument> + <description> + Sets the k1 lens constant. + </description> + </method> + <method name="set_k2"> + <return type="void"> + </return> + <argument index="0" name="k" type="float"> + </argument> + <description> + Sets the k2 lens constant. + </description> + </method> + <method name="set_oversample"> + <return type="void"> + </return> + <argument index="0" name="oversample" type="float"> + </argument> + <description> + Sets the oversampling setting. + </description> + </method> + </methods> + <members> + <member name="display_to_lens" type="float" setter="set_display_to_lens" getter="get_display_to_lens"> + The distance between the display and the lenses inside of the device in centimeters. + </member> + <member name="display_width" type="float" setter="set_display_width" getter="get_display_width"> + The width of the display in centimeters. + </member> + <member name="iod" type="float" setter="set_iod" getter="get_iod"> + The interocular distance, also known as the interpupillary distance. The distance between the pupils of the left and right eye. + </member> + <member name="k1" type="float" setter="set_k1" getter="get_k1"> + The k1 lens factor is one of the two constants that define the strength of the lens used and directly influences the lens distortion effect. + </member> + <member name="k2" type="float" setter="set_k2" getter="get_k2"> + The k2 lens factor, see k1. + </member> + <member name="oversample" type="float" setter="set_oversample" getter="get_oversample"> + The oversample setting. Because of the lens distortion we have to render our buffers at a higher resolution then the screen can natively handle. A value between 1.5 and 2.0 often provides good results but at the cost of performance. + </member> + </members> + <constants> + </constants> +</class> diff --git a/modules/mobile_vr/mobile_interface.cpp b/modules/mobile_vr/mobile_interface.cpp index f5c9bccaba..eb87bb2cf0 100644 --- a/modules/mobile_vr/mobile_interface.cpp +++ b/modules/mobile_vr/mobile_interface.cpp @@ -37,6 +37,10 @@ StringName MobileVRInterface::get_name() const { return "Native mobile"; }; +int MobileVRInterface::get_capabilities() const { + return ARVRInterface::ARVR_STEREO; +}; + Vector3 MobileVRInterface::scale_magneto(const Vector3 &p_magnetometer) { // Our magnetometer doesn't give us nice clean data. // Well it may on Mac OS X because we're getting a calibrated value in the current implementation but Android we're getting raw data. @@ -166,6 +170,8 @@ void MobileVRInterface::set_position_from_sensors() { rotate.rotate(orientation.get_axis(1), gyro.y * delta_time); rotate.rotate(orientation.get_axis(2), gyro.z * delta_time); orientation = rotate * orientation; + + tracking_state = ARVRInterface::ARVR_NORMAL_TRACKING; }; ///@TODO improve this, the magnetometer is very fidgity sometimes flipping the axis for no apparent reason (probably a bug on my part) @@ -176,6 +182,8 @@ void MobileVRInterface::set_position_from_sensors() { Quat acc_mag_quat(combine_acc_mag(grav, magneto)); transform_quat = transform_quat.slerp(acc_mag_quat, 0.1); orientation = Basis(transform_quat); + + tracking_state = ARVRInterface::ARVR_NORMAL_TRACKING; } else if (has_grav) { // use gravity vector to make sure down is down... // transform gravity into our world space @@ -273,21 +281,6 @@ real_t MobileVRInterface::get_k2() const { return k2; }; -bool MobileVRInterface::is_installed() { - // we don't have any middle ware here, if we have our interface, we can use it - return true; -}; - -bool MobileVRInterface::hmd_is_present() { - // our device is our HMD - return true; -}; - -bool MobileVRInterface::supports_hmd() { - // our device is our HMD - return true; -}; - bool MobileVRInterface::is_stereo() { // needs stereo... return true; @@ -461,11 +454,11 @@ MobileVRInterface::MobileVRInterface() { // Just set some defaults for these. At some point we need to look at adding a lookup table for common device + headset combos and/or support reading cardboard QR codes eye_height = 1.85; intraocular_dist = 6.0; - display_width = 13.0; + display_width = 14.5; display_to_lens = 4.0; oversample = 1.5; - k1 = 0.22; - k2 = 0.23; + k1 = 0.215; + k2 = 0.215; last_ticks = 0; // create our shader stuff diff --git a/modules/mobile_vr/mobile_interface.h b/modules/mobile_vr/mobile_interface.h index dfe3cd200e..6a5e01c163 100644 --- a/modules/mobile_vr/mobile_interface.h +++ b/modules/mobile_vr/mobile_interface.h @@ -131,10 +131,7 @@ public: real_t get_k2() const; virtual StringName get_name() const; - - virtual bool is_installed(); - virtual bool hmd_is_present(); - virtual bool supports_hmd(); + virtual int get_capabilities() const; virtual bool is_initialized(); virtual bool initialize(); |