public void Update() { if (WaveVR_Render.Instance != null) { this.Head = WaveVR_Render.Instance.gameObject; } if (this.Head != null) { gameObject.transform.localPosition = this.Head.transform.localPosition; gameObject.transform.localRotation = this.Head.transform.localRotation; } if (!this.EnableInputModule) { disableAllInputModules(); return; } updateInteractionModeAndGazeTriggerType(); WVR_InteractionMode _cur_mode = this.GetInteractionMode(); if (this.InteractionMode_Current != _cur_mode) { PrintDebugLog("Update() current interaction mode: " + _cur_mode); this.InteractionMode_Current = _cur_mode; WaveVR_Utils.Event.Send(WaveVR_Utils.Event.INTERACTION_MODE_CHANGED, this.InteractionMode_Current, this.AlwaysShowController); } }
public WVR_InteractionMode GetInteractionMode() { WVR_InteractionMode _custom_mode = (this.InteractionMode_User == WaveVR_EInputModule.Controller) ? WVR_InteractionMode.WVR_InteractionMode_Controller : WVR_InteractionMode.WVR_InteractionMode_Gaze; return((OverrideSystemSettings) ? _custom_mode : this.InteractionMode_System); }
private void updateInteractionModeAndGazeTriggerType() { if (this.OverrideSystemSettings) { if ((this.InteractionMode_User != this.CustomInputModule) || (this.preOverrideSystemSettings != this.OverrideSystemSettings)) { if (this.InteractionMode_User != this.CustomInputModule) { this.InteractionMode_User = this.CustomInputModule; PrintDebugLog("updateInteractionModeAndGazeTriggerType() Set interaction mode " + this.InteractionMode_User + " due to CustomInputModule changed."); } if (this.preOverrideSystemSettings != this.OverrideSystemSettings) { this.preOverrideSystemSettings = this.OverrideSystemSettings; PrintDebugLog("updateInteractionModeAndGazeTriggerType() Set interaction mode " + this.InteractionMode_User + " due to OverrideSystemSettings changed."); } if (!Application.isEditor) { WVR_InteractionMode _mode = (this.InteractionMode_User == WaveVR_EInputModule.Controller) ? WVR_InteractionMode.WVR_InteractionMode_Controller : WVR_InteractionMode.WVR_InteractionMode_Gaze; Interop.WVR_SetInteractionMode(_mode); } } updateGazeTriggerType_User(); if (this.gazeTriggerType_User_pre != this.gazeTriggerType_User) { this.gazeTriggerType_User_pre = this.gazeTriggerType_User; if (!Application.isEditor) { Interop.WVR_SetGazeTriggerType(this.gazeTriggerType_User); } PrintDebugLog("updateInteractionModeAndGazeTriggerType() Gaze Trigger - User: " + this.gazeTriggerType_User_pre); } updateInputModuleByCustomSettings(); } else { if (this.preOverrideSystemSettings != this.OverrideSystemSettings) { this.preOverrideSystemSettings = this.OverrideSystemSettings; // Restore runtime mirror system setting. if (!Application.isEditor) { Interop.WVR_SetInteractionMode(WVR_InteractionMode.WVR_InteractionMode_SystemDefault); } } if (!Application.isEditor) { this.InteractionMode_System = Interop.WVR_GetInteractionMode(); this.gazeTriggerType_System = Interop.WVR_GetGazeTriggerType(); } updateInputModuleBySystemSetting(); } }
public bool SetInteractionMode(WVR_InteractionMode mode) { if (mode == WVR_InteractionMode.WVR_InteractionMode_Gaze) { interactionMode = WVR_InteractionMode.WVR_InteractionMode_Gaze; } else { interactionMode = WVR_InteractionMode.WVR_InteractionMode_Controller; } return(true); }
void Update() { if (!Application.isEditor) { if (gameObject != null) { Log.gpl.d(LOG_TAG, "Update() showTrackedObject ? " + this.showTrackedObject + ", GameObject " + gameObject.name + " is " + (gameObject.activeSelf ? "shown." : "hidden.")); } foreach (var _obj in IncludedObjects) { Log.gpl.d(LOG_TAG, "Update() GameObject " + _obj.name + " is " + (_obj.activeSelf ? "shown." : "hidden.")); } } if (!this.connected) { return; } bool _focus = false; if (WaveVR.Instance != null) { _focus = WaveVR.Instance.FocusCapturedBySystem; } if (this.mFocusCapturedBySystem != _focus) { // InputFocus changed! this.mFocusCapturedBySystem = _focus; PrintDebugLog("Update() focus is " + (this.mFocusCapturedBySystem ? "captured by system." : "not captured by system.")); } if (WaveVR_InputModuleManager.Instance != null) { WVR_InteractionMode _imode = WaveVR_InputModuleManager.Instance.GetInteractionMode(); bool _gazeOnly = (_imode == WVR_InteractionMode.WVR_InteractionMode_Gaze) ? true : false; if (this.gazeOnly != _gazeOnly) { this.gazeOnly = _gazeOnly; PrintDebugLog("Update() interaction mode is " + (this.gazeOnly ? "Gaze only." : "NOT Gaze only.")); } } ActivateTargetObjects(); // Update after the frame receiving 1st new pose. this.poseUpdated = this.hasNewPose; }
private void initInteractionModeAndGazeTriggerType() { this.preOverrideSystemSettings = this.OverrideSystemSettings; this.InteractionMode_User = this.CustomInputModule; updateGazeTriggerType_User(); // set gazeTriggerType_User if (this.OverrideSystemSettings) { if (!Application.isEditor) { // Get default system settings. this.InteractionMode_System = Interop.WVR_GetInteractionMode(); this.gazeTriggerType_System = Interop.WVR_GetGazeTriggerType(); WVR_InteractionMode _mode = (this.InteractionMode_User == WaveVR_EInputModule.Controller) ? WVR_InteractionMode.WVR_InteractionMode_Controller : WVR_InteractionMode.WVR_InteractionMode_Gaze; // Change system settings to user settings. Interop.WVR_SetInteractionMode(_mode); Interop.WVR_SetGazeTriggerType(this.gazeTriggerType_User); this.gazeTriggerType_User_pre = this.gazeTriggerType_User; } // Initialize by user settings. initializeInputModuleByCustomSettings(); } else { if (!Application.isEditor) { // Reset runtime settings to system default if no override. Interop.WVR_SetInteractionMode(WVR_InteractionMode.WVR_InteractionMode_SystemDefault); // Get default system settings. this.InteractionMode_System = Interop.WVR_GetInteractionMode(); this.gazeTriggerType_System = Interop.WVR_GetGazeTriggerType(); } // Initialize by system settings. initializeInputModuleBySystemSetting(); } this.InteractionMode_Current = GetInteractionMode(); PrintDebugLog("initInteractionModeAndGazeTriggerType() OverrideSystemSettings: " + OverrideSystemSettings); PrintDebugLog("initInteractionModeAndGazeTriggerType() Interaction Mode - System: " + this.InteractionMode_System + ", User: "******", Current: " + this.InteractionMode_Current); PrintDebugLog("initInteractionModeAndGazeTriggerType() Gaze Trigger - System: " + this.gazeTriggerType_System + ", User: " + this.gazeTriggerType_User); }
private void onInteractionModeChange(params object[] args) { if (!ptmEnabled) { PrintDebugLog("onInteractionModeChange() do NOTHING when disabled."); return; } WVR_InteractionMode _imode = (WVR_InteractionMode)args [0]; this.gazeOnly = (_imode == WVR_InteractionMode.WVR_InteractionMode_Gaze) ? true : false; bool _hide = hideEventController(); PrintDebugLog("onInteractionModeChange() interaction mode is " + _imode + ", controller in gaze? " + _hide); ActivateTargetObjects(); }
public void Update() { if (WaveVR_Render.Instance != null) { this.Head = WaveVR_Render.Instance.gameObject; } // For Gaze if (this.Head != null) { gameObject.transform.position = this.Head.transform.position; gameObject.transform.rotation = this.Head.transform.rotation; } if (!this.EnableInputModule) { disableAllInputModules(); return; } if (WaveVR.Instance.FocusCapturedBySystem) { return; } updateInteractionModeAndGazeTriggerType(); WVR_InteractionMode _cur_mode = this.GetInteractionMode(); if (InteractionMode_Current != _cur_mode) { InteractionMode_Current = _cur_mode; if (InteractionMode_Current == WVR_InteractionMode.WVR_InteractionMode_Controller) { DEBUG("Update() InteractionMode_Current is controller."); } if (InteractionMode_Current == WVR_InteractionMode.WVR_InteractionMode_Gaze) { DEBUG("Update() InteractionMode_Current is gaze."); } WaveVR_Utils.Event.Send(WaveVR_Utils.Event.INTERACTION_MODE_CHANGED, InteractionMode_Current, this.AlwaysShowController); } }
private bool hideEventController() { bool _hide = false; WVR_InteractionMode _imode = WaveVR.Instance.InteractionMode; if (WaveVR_InputModuleManager.Instance != null) { _imode = WaveVR_InputModuleManager.Instance.GetInteractionMode(); } this.gazeOnly = _imode == WVR_InteractionMode.WVR_InteractionMode_Gaze ? true : false; GameObject _model = WaveVR_EventSystemControllerProvider.Instance.GetControllerModel(this.Type); if (GameObject.ReferenceEquals(gameObject, _model)) { _hide = this.gazeOnly; } return(_hide); }
void LateUpdate() { string text = ""; #if UNITY_EDITOR Debug.Log(LOG_TAG + " " + "LateUpdate"); #endif string gaze_type_text = ""; string ctrlr_mode_text = ""; if (WaveVR_InputModuleManager.Instance != null) { WVR_InteractionMode mode = WaveVR_InputModuleManager.Instance.GetInteractionMode(); if (mode == WVR_InteractionMode.WVR_InteractionMode_SystemDefault || mode == WVR_InteractionMode.WVR_InteractionMode_Controller) { switch (WaveVR_InputModuleManager.Instance.GetRaycastMode()) { case ERaycastMode.Beam: ctrlr_mode_text = "Controller(FlexibleBeam mode)"; break; case ERaycastMode.Fixed: ctrlr_mode_text = "Controller(FixedBeam mode)"; break; case ERaycastMode.Mouse: ctrlr_mode_text = "Controller(FixedMouse mode)"; break; default: ctrlr_mode_text = "Controller(--)"; break; } text += ctrlr_mode_text; if (mode == WVR_InteractionMode.WVR_InteractionMode_SystemDefault) { text += ", "; } } if (mode == WVR_InteractionMode.WVR_InteractionMode_SystemDefault || mode == WVR_InteractionMode.WVR_InteractionMode_Gaze) { //Log.d(LOG_TAG, "wvr: " + Interop.WVR_GetGazeTriggerType().ToString()); //Log.d(LOG_TAG, "WaveVR_InputModuleManager: " + WaveVR_InputModuleManager.Instance.GetGazeTriggerType().ToString()); switch (WaveVR_InputModuleManager.Instance.GetGazeTriggerType()) { case WVR_GazeTriggerType.WVR_GazeTriggerType_Button: gaze_type_text = "Gaze(Button Trigger)"; break; case WVR_GazeTriggerType.WVR_GazeTriggerType_Timeout: gaze_type_text = "Gaze(Timeout Trigger)"; break; case WVR_GazeTriggerType.WVR_GazeTriggerType_TimeoutButton: gaze_type_text = "Gaze(Button and Timeout Trigger)"; break; default: gaze_type_text = "Gaze(--)"; break; } text += gaze_type_text; } } textField.text = text; }
public static extern bool WVR_SetInteractionMode_Android(WVR_InteractionMode mode);
public override bool SetInteractionMode(WVR_InteractionMode mode) { return(WVR_SetInteractionMode_Android(mode)); }
public void UpdateEachFrame(WVR_PoseOriginModel origin, bool isSimulator) { if (!this.Initialized) { return; } if (Log.gpl.Print) { PrintDebugLog("UpdateEachFrame()"); } bool _focusCapturedBySystem = Interop.WVR_IsInputFocusCapturedBySystem(); if (this.FocusCapturedBySystem != _focusCapturedBySystem) { this.FocusCapturedBySystem = _focusCapturedBySystem; WaveVR_Utils.Event.Send(WaveVR_Utils.Event.SYSTEMFOCUS_CHANGED, this.FocusCapturedBySystem); // When getting system focus again, reset button events. if (!this.FocusCapturedBySystem) { PrintInfoLog("UpdateEachFrame() get system focus, update button events."); UpdateButtonEvents(); } else { PrintInfoLog("UpdateEachFrame() lost system focus."); } } InteractionMode = Interop.WVR_GetInteractionMode(); GazeTriggerType = Interop.WVR_GetGazeTriggerType(); Profiler.BeginSample("GetSyncPose"); #if UNITY_STANDALONE Interop.WVR_GetLastPoseIndex(origin, poses, (uint)poses.Length, ref frameInx); #else Interop.WVR_GetSyncPose(origin, poses, (uint)poses.Length); #endif Profiler.EndSample(); for (uint i = 0; i < DeviceTypes.Length; i++) { bool _hasType = false; for (uint j = 0; j < poses.Length; j++) { WVR_DevicePosePair_t _pose = poses[j]; if (_pose.type == DeviceTypes [i]) { _hasType = true; // Check connection first bool _valid_pose = GetConnectionStatus(DeviceTypes [i]); // Check whether pose is valid with connection. if (_valid_pose) { _valid_pose = _pose.pose.IsValidPose; } deviceIndexMap[i] = j; if (isValidPose [i] != _valid_pose) { isValidPose [i] = _valid_pose; PrintInfoLog(Log.CSB.Append("UpdateEachFrame() device ").Append(DeviceTypes [i].Name()).Append(" pose is ").Append(isValidPose [i] ? "valid." : "invalid.").ToString()); WaveVR_Utils.Event.Send(WaveVR_Utils.Event.DEVICE_CONNECTED, DeviceTypes [i], isValidPose [i]); } if (isValidPose [i]) { rtPoses[j].update(_pose.pose.PoseMatrix); } break; } } // no such type if (!_hasType) { if (isValidPose [i] == true) { isValidPose [i] = false; PrintInfoLog(Log.CSB.Append("UpdateEachFrame() device ").Append(DeviceTypes [i].Name()).Append(" pose is invalid.").ToString()); WaveVR_Utils.Event.Send(WaveVR_Utils.Event.DEVICE_CONNECTED, DeviceTypes [i], isValidPose [i]); } } } for (int i = 0; i < poses.Length; i++) { WVR_DeviceType _type = poses [i].type; bool _connected = GetConnectionStatus(_type); bool _poseValid = poses [i].pose.IsValidPose; if (Log.gpl.Print) { PrintDebugLog( Log.CSB .Append("UpdateEachFrame() device ").Append(_type.Name()).Append(" is ").Append(_connected ? "connected" : "disconnected") .Append(", pose is ").Append(_poseValid ? "valid" : "invalid") .Append(", pos: {").Append(rtPoses [i].pos.x).Append(", ").Append(rtPoses [i].pos.y).Append(", ").Append(rtPoses [i].pos.z).Append("}") .Append(", rot: {").Append(rtPoses [i].rot.x).Append(", ").Append(rtPoses [i].rot.y).Append(", ").Append(rtPoses [i].rot.z).Append(", ").Append(rtPoses [i].rot.w).Append("}") .ToString()); } } Profiler.BeginSample("SendNewPose"); try { WaveVR_Utils.Event.Send(WaveVR_Utils.Event.NEW_POSES, poses, rtPoses); } catch (Exception ex) { PrintErrorLog("Send NEW_POSES Event Exception : " + ex); } if (Log.gpl.Print) { PrintDebugLog("UpdateEachFrame() after new pose."); } try { WaveVR_Utils.Event.Send(WaveVR_Utils.Event.AFTER_NEW_POSES); } catch (Exception ex) { PrintErrorLog("Send AFTER_NEW_POSES Event Exception : " + ex); } Profiler.EndSample(); }
void LateUpdate() { string text = ""; string gaze_type_text = ""; string ctrlr_mode_text = ""; if (WaveVR_InputModuleManager.Instance != null) { WVR_InteractionMode mode = WaveVR_InputModuleManager.Instance.GetInteractionMode(); switch (mode) { case WVR_InteractionMode.WVR_InteractionMode_Controller: switch (WaveVR_InputModuleManager.Instance.GetRaycastMode()) { case WaveVR_ControllerInputModule.ERaycastMode.Beam: ctrlr_mode_text = "Controller(FlexibleBeam mode)"; break; case WaveVR_ControllerInputModule.ERaycastMode.Fixed: ctrlr_mode_text = "Controller(FixedBeam mode)"; break; case WaveVR_ControllerInputModule.ERaycastMode.Mouse: ctrlr_mode_text = "Controller(FixedMouse mode)"; break; default: ctrlr_mode_text = "Controller(--)"; break; } text += ctrlr_mode_text; break; case WVR_InteractionMode.WVR_InteractionMode_Gaze: switch (WaveVR_InputModuleManager.Instance.GetGazeTriggerType()) { case WVR_GazeTriggerType.WVR_GazeTriggerType_Button: gaze_type_text = "Gaze(Button Trigger)"; break; case WVR_GazeTriggerType.WVR_GazeTriggerType_Timeout: gaze_type_text = "Gaze(Timeout Trigger)"; break; case WVR_GazeTriggerType.WVR_GazeTriggerType_TimeoutButton: gaze_type_text = "Gaze(Button and Timeout Trigger)"; break; default: gaze_type_text = "Gaze(--)"; break; } text += gaze_type_text; break; default: break; } } textField.text = text; }
private void updateInteractionModeAndGazeTriggerType() { if (Log.gpl.Print) { DEBUG(this.OverrideSystemSettings ? "updateInteractionModeAndGazeTriggerType() OverrideSystemSettings is true." : "updateInteractionModeAndGazeTriggerType() OverrideSystemSettings is false."); DEBUG(InteractionMode_System == WVR_InteractionMode.WVR_InteractionMode_Gaze ? "updateInteractionModeAndGazeTriggerType() InteractionMode_System is gaze." : "updateInteractionModeAndGazeTriggerType() InteractionMode_System is controller."); DEBUG(InteractionMode_User == WaveVR_EInputModule.Controller ? "updateInteractionModeAndGazeTriggerType() InteractionMode_User is controller." : "updateInteractionModeAndGazeTriggerType() InteractionMode_User is gaze."); if (gazeTriggerType_System == WVR_GazeTriggerType.WVR_GazeTriggerType_Timeout) { DEBUG("updateInteractionModeAndGazeTriggerType() gazeTriggerType_System is timeout."); } if (gazeTriggerType_System == WVR_GazeTriggerType.WVR_GazeTriggerType_Button) { DEBUG("updateInteractionModeAndGazeTriggerType() gazeTriggerType_System is button."); } if (gazeTriggerType_System == WVR_GazeTriggerType.WVR_GazeTriggerType_TimeoutButton) { DEBUG("updateInteractionModeAndGazeTriggerType() gazeTriggerType_System is timeout & button."); } if (gazeTriggerType_User == WVR_GazeTriggerType.WVR_GazeTriggerType_Timeout) { DEBUG("updateInteractionModeAndGazeTriggerType() gazeTriggerType_User is timeout."); } if (gazeTriggerType_User == WVR_GazeTriggerType.WVR_GazeTriggerType_Button) { DEBUG("updateInteractionModeAndGazeTriggerType() gazeTriggerType_User is button."); } if (gazeTriggerType_User == WVR_GazeTriggerType.WVR_GazeTriggerType_TimeoutButton) { DEBUG("updateInteractionModeAndGazeTriggerType() gazeTriggerType_User is timeout & button."); } } if (this.OverrideSystemSettings) { if ((this.InteractionMode_User != this.CustomInputModule) || (this.preOverrideSystemSettings != this.OverrideSystemSettings)) { if (this.InteractionMode_User != this.CustomInputModule) { this.InteractionMode_User = this.CustomInputModule; DEBUG(this.InteractionMode_User == WaveVR_EInputModule.Controller ? "updateInteractionModeAndGazeTriggerType() InteractionMode_User is controller." : "updateInteractionModeAndGazeTriggerType() InteractionMode_User is gaze."); } if (this.preOverrideSystemSettings != this.OverrideSystemSettings) { this.preOverrideSystemSettings = this.OverrideSystemSettings; DEBUG(this.OverrideSystemSettings ? "updateInteractionModeAndGazeTriggerType() OverrideSystemSettings is true." : "updateInteractionModeAndGazeTriggerType() OverrideSystemSettings is false."); } WVR_InteractionMode _mode = (this.InteractionMode_User == WaveVR_EInputModule.Controller) ? WVR_InteractionMode.WVR_InteractionMode_Controller : WVR_InteractionMode.WVR_InteractionMode_Gaze; Interop.WVR_SetInteractionMode(_mode); } updateGazeTriggerType_User(); if (this.gazeTriggerType_User_pre != this.gazeTriggerType_User) { this.gazeTriggerType_User_pre = this.gazeTriggerType_User; Interop.WVR_SetGazeTriggerType(this.gazeTriggerType_User); if (gazeTriggerType_User == WVR_GazeTriggerType.WVR_GazeTriggerType_Timeout) { DEBUG("updateInteractionModeAndGazeTriggerType() gazeTriggerType_User is timeout."); } if (gazeTriggerType_User == WVR_GazeTriggerType.WVR_GazeTriggerType_Button) { DEBUG("updateInteractionModeAndGazeTriggerType() gazeTriggerType_User is button."); } if (gazeTriggerType_User == WVR_GazeTriggerType.WVR_GazeTriggerType_TimeoutButton) { DEBUG("updateInteractionModeAndGazeTriggerType() gazeTriggerType_User is timeout & button."); } } updateInputModuleByCustomSettings(); } else { if (this.preOverrideSystemSettings != this.OverrideSystemSettings) { this.preOverrideSystemSettings = this.OverrideSystemSettings; // Restore runtime mirror system setting. Interop.WVR_SetInteractionMode(WVR_InteractionMode.WVR_InteractionMode_SystemDefault); } this.InteractionMode_System = WaveVR.Instance.InteractionMode; this.gazeTriggerType_System = WaveVR.Instance.GazeTriggerType; updateInputModuleBySystemSetting(); } }
public static extern bool WVR_SetInteractionMode_HVR(WVR_InteractionMode mode);
public override bool SetInteractionMode(WVR_InteractionMode mode) { return(system.SetInteractionMode(mode)); }