private void onDeviceRoleChanged(params object[] args)
    {
        PrintDebugLog("onDeviceRoleChanged() ");
        WVR_DeviceType _type = WVR_DeviceType.WVR_DeviceType_Invalid;

        this.connected = false;
        isProcessing   = false;

        if (!checkChild())
        {
            PrintDebugLog("delete sub-models when onDeviceRoleChanged");
            deleteChild();
        }

        WaveVR.Device _dev = WaveVR.Instance.getDeviceByType(this.deviceType);
        if (_dev != null)
        {
            this.connected = _dev.connected;
            _type          = _dev.type;

            PrintDebugLog("onDeviceRoleChanged() device " + _type + " is " + (this.connected ? "connected." : "disconnected."));

            if (this.connected)
            {
                onLoadController(_type);
            }
        }
    }
Ejemplo n.º 2
0
    void OnEnable()
    {
        PrintDebugLog("OnEnable");

        if (WhichHand == ControllerHand.Controller_Right)
        {
            deviceType = WVR_DeviceType.WVR_DeviceType_Controller_Right;
        }
        else
        {
            deviceType = WVR_DeviceType.WVR_DeviceType_Controller_Left;
        }

        connected = checkConnection();

        if (connected)
        {
            PrintDebugLog("Controller load when connected!");

            WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.deviceType);
            onLoadController(_device.type);
        }

        WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.DEVICE_CONNECTED, onDeviceConnected);
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        #if UNITY_EDITOR
        if (Application.isEditor)
        {
            return;
        }
        #endif

        WaveVR.Device  _device = WaveVR.Instance.getDeviceByType(this.index);
        WVR_DeviceType _type   = _device.type;

        Interop.WVR_GetSyncPose(origin, poses, (uint)poses.Length);

        Log.d(LOG_TAG, "Update() poses length = " + poses.Length);
        for (int i = 0; i < poses.Length; i++)
        {
            Log.d(LOG_TAG, "Update() pose[" + i + "] type = " + poses [i].type
                  + " pose is " + (poses [i].pose.IsValidPose ? "valid" : "invalid"));
            if (poses[i].type == _type && poses[i].pose.IsValidPose)
            {
                rtPoses [i].update(poses [i].pose.PoseMatrix);
                updatePose(rtPoses [i]);
                break;
            }
        }
    }
    void Update()
    {
        // FollowHead changes in runtime.
        if (this.FollowHead != this.currFollowHead)
        {
            this.bSetupFollowHead = false;
        }
        // SimulationOption changes in runtime.
        if (this.SimulationOption != this.currSimulationOption)
        {
            this.bSetupSimulation = false;
        }
        SetupPoseSimulation();

        if (TrackTiming == WVR_TrackTiming.WhenNewPoses)
        {
            return;
        }
        if (!WaveVR.Instance.Initialized)
        {
            return;
        }

        WaveVR.Device device = WaveVR.Instance.getDeviceByType(this.Type);
        if (device.connected)
        {
            wvr_pose   = device.pose;
            rigid_pose = device.rigidTransform;
        }

        updateDevicePose(wvr_pose, rigid_pose);
    }
Ejemplo n.º 5
0
    private void onDeviceConnected(params object[] args)
    {
        bool           _connected = false;
        WVR_DeviceType _type      = this.type;

#if UNITY_EDITOR && UNITY_ANDROID
        if (Application.isEditor)
        {
            _connected = WaveVR_Controller.Input(this.type).connected;
            _type      = WaveVR_Controller.Input(this.type).DeviceType;
        }
        else
#endif
        {
            WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.type);
            _connected = _device.connected;
            _type      = _device.type;
        }

        PrintDebugLog("onDeviceConnected() " + _type + " is " + (_connected ? "connected" : "disconnected") + ", left-handed? " + WaveVR_Controller.IsLeftHanded);

        if (connected != _connected)
        {
            connected = _connected;
            setActive(connected && (!mFocusCapturedBySystem));
        }
    }
Ejemplo n.º 6
0
    void OnEnable()
    {
        if (!ptmEnabled)
        {
            IncludedObjects.Clear();
            IncludedStates.Clear();
            int _children_count = transform.childCount;
            for (int i = 0; i < _children_count; i++)
            {
                IncludedObjects.Add(transform.GetChild(i).gameObject);
                IncludedStates.Add(transform.GetChild(i).gameObject.activeSelf);
                PrintDebugLog("OnEnable() " + this.Type + ", " + gameObject.name + " has child: " + IncludedObjects [i].name + ", active? " + IncludedStates [i]);
            }

            // If pose is invalid, considering as disconnected and not show controller.
            WaveVR.Device _device = WaveVR.Instance.getDeviceByType(Type);
            this.connected = _device.connected;

            // Always hide Pose Tracker objects when enabled.
            // Check whether to show object when:
            // 1. device connected
            // 2. pose updated
            // 3. system focus changed
            // 4. interaction mode changed
            ForceActivateTargetObjects(false);
            this.poseUpdated = false;
            this.hasNewPose  = false;

            WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.DEVICE_CONNECTED, onDeviceConnected);
            WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.NEW_POSES, OnNewPoses);
            WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.SYSTEMFOCUS_CHANGED, onSystemFocusChanged);

            ptmEnabled = true;
        }
    }
Ejemplo n.º 7
0
    private void onDeviceConnected(params object[] args)
    {
        if (!ptmEnabled)
        {
            PrintDebugLog("onDeviceConnected() do NOTHING when disabled.");
            return;
        }

        bool           _connected = false;
        WVR_DeviceType _type      = this.Type;

        #if UNITY_EDITOR
        if (Application.isEditor)
        {
            _connected = WaveVR_Controller.Input(this.Type).connected;
            _type      = WaveVR_Controller.Input(this.Type).DeviceType;
        }
        else
        #endif
        {
            WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.Type);
            _connected = _device.connected;
            _type      = _device.type;
        }

        PrintDebugLog("onDeviceConnected() " + _type + " is " + (_connected ? "connected" : "disconnected") + ", left-handed? " + WaveVR_Controller.IsLeftHanded);

        if (this.connected != _connected)
        {
            this.connected = _connected;
            ActivateTargetObjects(this.connected && (!mFocusCapturedBySystem));
        }
    }
Ejemplo n.º 8
0
    void OnEnable()
    {
        if (!ptmEnabled)
        {
            int _children_count = transform.childCount;
            IncludedObjects = new GameObject[_children_count];
            IncludedStates  = new bool[_children_count];
            for (int i = 0; i < _children_count; i++)
            {
                IncludedObjects [i] = transform.GetChild(i).gameObject;
                IncludedStates [i]  = transform.GetChild(i).gameObject.activeSelf;
                PrintDebugLog("OnEnable() " + gameObject.name + " has child: " + IncludedObjects [i].name + ", active? " + IncludedStates [i]);
            }

            #if UNITY_EDITOR
            if (Application.isEditor)
            {
                this.connected = true; // WaveVR_Controller.Input (Type).connected;
            }
            else
            #endif
            {
                // If pose is invalid, considering as disconnected and not show controller.
                WaveVR.Device _device = WaveVR.Instance.getDeviceByType(Type);
                this.connected = _device.connected;
            }
            PrintDebugLog("OnEnable() is " + (this.connected ? "connected" : "disconnected") + ", mFocusCapturedBySystem: " + mFocusCapturedBySystem);
            ActivateTargetObjects(this.connected && (!mFocusCapturedBySystem));

            WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.DEVICE_CONNECTED, onDeviceConnected);

            ptmEnabled = true;
        }
    }
    void Update()
    {
        mFPS = 1.0f / Time.deltaTime;

        // FollowHead changes in runtime.
        if (this.FollowHead != this.currFollowHead)
        {
            this.bSetupFollowHead = false;
        }
        // SimulationOption changes in runtime.
        if (this.SimulationOption != this.currSimulationOption)
        {
            this.bSetupSimulation = false;
        }
        SetupPoseSimulation();

        if (TrackTiming == WVR_TrackTiming.WhenNewPoses)
        {
            return;
        }
        if (WaveVR.Instance == null)
        {
            return;
        }

        WaveVR.Device device = WaveVR.Instance.getDeviceByType(this.Type);
        if (device.connected)
        {
            updatePose(device.pose, device.rigidTransform);
        }
    }
Ejemplo n.º 10
0
    private void checkConnection()
    {
        bool _connected_D = false, _connected_ND = false;

        WaveVR.Device _dev_D = WaveVR.Instance.getDeviceByType(WaveVR_Controller.EDeviceType.Dominant);
        if (_dev_D != null)
        {
            _connected_D = _dev_D.connected;
        }

        WaveVR.Device _dev_ND = WaveVR.Instance.getDeviceByType(WaveVR_Controller.EDeviceType.NonDominant);
        if (_dev_ND != null)
        {
            _connected_ND = _dev_ND.connected;
        }

        if (ControllerConnected [(uint)CIndex.Dominant] != _connected_D)
        {
            PrintDebugLog("checkConnection() dominant device  is " + (_connected_D == true ? "connected" : "disconnected")
                          + ", left-handed? " + WaveVR_Controller.IsLeftHanded);
            ControllerConnected [(uint)CIndex.Dominant] = _connected_D;
            BroadcastToObjects(CIndex.Dominant);
        }

        if (ControllerConnected [(uint)CIndex.NonDominant] != _connected_ND)
        {
            PrintDebugLog("checkConnection() non-dominant device  is " + (_connected_ND == true ? "connected" : "disconnected")
                          + ", left-handed? " + WaveVR_Controller.IsLeftHanded);
            ControllerConnected [(uint)CIndex.NonDominant] = _connected_ND;
            BroadcastToObjects(CIndex.NonDominant);
        }
    }
Ejemplo n.º 11
0
    private void onDeviceConnected(params object[] args)
    {
        bool           _connected = false;
        WVR_DeviceType _type      = this.deviceType;

        #if UNITY_EDITOR
        if (Application.isEditor)
        {
            _connected = WaveVR_Controller.Input(this.deviceType).connected;
            _type      = WaveVR_Controller.Input(this.deviceType).DeviceType;
        }
        else
        #endif
        {
            WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.deviceType);
            _connected = _device.connected;
            _type      = _device.type;
        }

        PrintDebugLog("onDeviceConnected() " + _type + " is " + (_connected ? "connected" : "disconnected") + ", left-handed? " + WaveVR_Controller.IsLeftHanded);

        if (connected != _connected)
        {
            connected = _connected;
        }

        if (connected)
        {
            if (controllerPrefab == null)
            {
                onLoadController(_type);
            }
        }
    }
Ejemplo n.º 12
0
    void updateBatteryLevel()
    {
        if (batteryGO != null)
        {
            if (showBatterIndicator && isBatteryIndicatorReady)
            {
                if ((modelResource == null) || (modelResource.batteryTextureList == null))
                {
                    return;
                }
                bool found = false;

                WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.deviceType);

                float batteryP = Interop.WVR_GetDeviceBatteryPercentage(_device.type);

                if (batteryP < 0)
                {
                    PrintDebugLog("updateBatteryLevel BatteryPercentage is negative, return");
                    batteryGO.SetActive(false);
                    return;
                }

                foreach (BatteryIndicator bi in modelResource.batteryTextureList)
                {
                    if (batteryP >= bi.min / 100 && batteryP <= bi.max / 100)
                    {
                        currentBattery = bi;
                        found          = true;
                        break;
                    }
                }

                if (found)
                {
                    if (batteryMR != null)
                    {
                        batteryMR.material.mainTexture = currentBattery.batteryTexture;
                        PrintDebugLog("updateBatteryLevel battery level to " + currentBattery.level + ", battery percent: " + batteryP);
                        batteryGO.SetActive(true);
                    }
                    else
                    {
                        PrintDebugLog("updateBatteryLevel Can't get battery mesh renderer");
                        batteryGO.SetActive(false);
                    }
                }
                else
                {
                    batteryGO.SetActive(false);
                }
            }
            else
            {
                batteryGO.SetActive(false);
            }
        }
    }
Ejemplo n.º 13
0
        public Vector2 GetAxis(WVR_InputId _id)
        {
            if (_id != WVR_InputId.WVR_InputId_Alias1_Touchpad && _id != WVR_InputId.WVR_InputId_Alias1_Trigger)
            {
                Log.e(LOG_TAG, "GetAxis, button " + _id + " does NOT have axis!");
                return(Vector2.zero);
            }

            bool           _connected = false;
            WVR_DeviceType _type      = this.DeviceType;

            #if UNITY_EDITOR || UNITY_STANDALONE
            if (isEditorMode)
            {
                _connected = WaveVR_Controller.Input(this.DeviceType).connected;
                _type      = WaveVR_Controller.Input(this.DeviceType).DeviceType;
            }
            else
            #endif
            {
                if (WaveVR.Instance != null)
                {
                    WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.DeviceType);
                    _connected = _device.connected;
                    _type      = _device.type;
                }
            }

            #if UNITY_EDITOR || UNITY_STANDALONE
            if (isEditorMode)
            {
                if (!WaveVR.Instance.isSimulatorOn)
                {
                    var system = WaveVR_PoseSimulator.Instance;
                    axis = system.GetAxis(_type, WVR_InputId.WVR_InputId_Alias1_Trigger);
                }
                else
                {
                    if (_connected)
                    {
                        axis = WaveVR_Utils.WVR_GetInputAnalogAxis_S((int)_type, (int)_id);
                    }
                }
            }
            else
            #endif
            {
                if (_connected)
                {
                    axis = Interop.WVR_GetInputAnalogAxis(_type, _id);
                }
            }

            //Log.d (LOG_TAG, "GetAxis: {" + axis.x + ", " + axis.y + "}");
            return(new Vector2(axis.x, axis.y));
        }
Ejemplo n.º 14
0
    private void onDeviceConnected(params object[] args)
    {
        WVR_DeviceType eventType = (WVR_DeviceType)args[0];
        WVR_DeviceType _type     = WVR_DeviceType.WVR_DeviceType_Invalid;

        bool _connected = false;

        {
            WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.deviceType);
            _connected = _device.connected;
            _type      = _device.type;

            if (eventType != _type)
            {
                PrintDebugLog("onDeviceConnected() event type is " + eventType + ", this.deviceType is " + _type + ", skip");
                return;
            }
        }

        PrintDebugLog("onDeviceConnected() " + _type + " is " + (_connected ? "connected" : "disconnected") + ", left-handed? " + WaveVR_Controller.IsLeftHanded);

        if (connected != _connected)
        {
            connected = _connected;

            if (connected)
            {
                if (mLoadingState == LoadingState.LoadingState_LOADED)
                {
                    if (isRenderModelNameSameAsPrevious())
                    {
                        PrintDebugLog("onDeviceConnected - Controller connected, model was loaded!");
                    }
                    else
                    {
                        deleteChild("Controller load when onDeviceConnected, render model is different!");
                        onLoadController(_type);
                    }
                }
                else
                {
                    if (mLoadingState == LoadingState.LoadingState_LOADING)
                    {
                        PrintDebugLog("onDeviceConnected - Controller connected, model is loading!");
                    }
                    else
                    {
                        PrintDebugLog("Controller load when onDeviceConnected!");
                        onLoadController(_type);
                    }
                }
            }
        }
    }
Ejemplo n.º 15
0
    private bool checkConnection()
    {
        bool           _connected = false;
        WVR_DeviceType _type      = WVR_DeviceType.WVR_DeviceType_Invalid;

        WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.device);
        _connected = _device.connected;
        _type      = _device.type;

        return(_connected);
    }
Ejemplo n.º 16
0
 private void onDeviceRoleChanged(params object[] args)
 {
     if (WaveVR.Instance != null)
     {
         WaveVR.Device _dev = WaveVR.Instance.getDeviceByType(this.Type);
         if (_dev != null)
         {
             this.connected = _dev.connected;
         }
     }
     PrintDebugLog("onDeviceRoleChanged() " + this.Type + " is " + (this.connected ? "connected." : "disconnected."));
 }
Ejemplo n.º 17
0
        public FocusControllerStatus(XRHand hand) : base(hand)
        {
            if (WaveVR.Instance == null)
            {
                Debug.LogError("WaveVR.Instance is null!");
                return;
            }
            var wvr_hand = hand == XRHand.Left ? WVR_DeviceType.WVR_DeviceType_Controller_Left : WVR_DeviceType.WVR_DeviceType_Controller_Right;

            device     = WaveVR.Instance.getDeviceByType(wvr_hand);
            controller = WaveVR_Controller.Input(wvr_hand);
        }
Ejemplo n.º 18
0
        private IVRModuleDeviceStateRW UpdateDevicePose(uint deviceIndex, WaveVR.Device content)
        {
            IVRModuleDeviceState   prevState;
            IVRModuleDeviceStateRW currState;

            EnsureValidDeviceState(deviceIndex, out prevState, out currState);

            var deviceConnected = content.type == WVR_DeviceType.WVR_DeviceType_HMD ? true : content.connected;

            if (!deviceConnected)
            {
                if (prevState.isConnected)
                {
                    currState.Reset();

                    switch (content.type)
                    {
                    case WVR_DeviceType.WVR_DeviceType_HMD: m_headState = null; break;

                    case WVR_DeviceType.WVR_DeviceType_Controller_Right: m_rightState = null; break;

                    case WVR_DeviceType.WVR_DeviceType_Controller_Left: m_leftState = null; break;
                    }
                }
            }
            else
            {
                if (!prevState.isConnected)
                {
                    currState.isConnected     = true;
                    currState.deviceClass     = s_type2class[(int)content.type];
                    currState.deviceModel     = s_type2model[(int)content.type];
                    currState.serialNumber    = content.type.ToString();
                    currState.modelNumber     = content.type.ToString();
                    currState.renderModelName = content.type.ToString();
                }

                // update pose
                var devicePose = content.pose.pose;
                currState.velocity        = new Vector3(devicePose.Velocity.v0, devicePose.Velocity.v1, -devicePose.Velocity.v2);
                currState.angularVelocity = new Vector3(-devicePose.AngularVelocity.v0, -devicePose.AngularVelocity.v1, devicePose.AngularVelocity.v2);

                var rigidTransform = content.rigidTransform;
                currState.position = rigidTransform.pos;
                currState.rotation = rigidTransform.rot;

                currState.isPoseValid = devicePose.IsValidPose;
            }

            return(currState);
        }
Ejemplo n.º 19
0
    void OnEnable()
    {
        PrintDebugLog("OnEnable");
        sessionid = 0;

        if (WhichHand == ControllerHand.Controller_Right)
        {
            deviceType = WaveVR_Controller.EDeviceType.Dominant;
        }
        else
        {
            deviceType = WaveVR_Controller.EDeviceType.NonDominant;
        }

        connected = checkConnection();

        if (connected)
        {
            WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.deviceType);
            if (!checkChild())
            {
                if (isProcessing)
                {
                    PrintDebugLog("OnEnable - Controller connected, model is loading!");
                }
                else
                {
                    PrintDebugLog("Controller load when OnEnable!");
                    onLoadController(_device.type);
                }
            }
            else
            {
                if (isRenderModelNameSameAsPrevious())
                {
                    PrintDebugLog("OnEnable - Controller connected, model was loaded!");
                }
                else
                {
                    PrintDebugLog("Controller load when OnEnable, render model is different!");
                    deleteChild();
                    onLoadController(_device.type);
                }
            }
        }
#if !UNITY_EDITOR
        WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.DEVICE_CONNECTED, onDeviceConnected);
        WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.DEVICE_ROLE_CHANGED, onDeviceRoleChanged);
        WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.OEM_CONFIG_CHANGED, onOEMConfigChanged);
#endif
    }
Ejemplo n.º 20
0
    void OnEnable()
    {
        if (!ptmEnabled)
        {
            int _children_count = transform.childCount;
            IncludedObjects = new GameObject[_children_count];
            IncludedStates  = new bool[_children_count];
            for (int i = 0; i < _children_count; i++)
            {
                IncludedObjects [i] = transform.GetChild(i).gameObject;
                IncludedStates [i]  = transform.GetChild(i).gameObject.activeSelf;
                PrintDebugLog("OnEnable() " + gameObject.name + " has child: " + IncludedObjects [i].name + ", active? " + IncludedStates [i]);
            }

            #if UNITY_EDITOR
            if (Application.isEditor)
            {
                this.connected = WaveVR_Controller.Input(Type).connected;
            }
            else
            #endif
            {
                // If pose is invalid, considering as disconnected and not show controller.
                WaveVR.Device _device = WaveVR.Instance.getDeviceByType(Type);
                this.connected = _device.connected;
            }

            // Always hide Pose Tracker objects when enabled.
            // Check whether to show object when:
            // 1. device connected
            // 2. pose updated
            // 3. system focus changed
            // 4. interaction mode changed
            ForceActivateTargetObjects(false);
            this.poseUpdated = false;
            this.hasNewPose  = false;

            WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.DEVICE_CONNECTED, onDeviceConnected);
            WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.DEVICE_ROLE_CHANGED, onDeviceRoleChanged);
            if (TrackTiming == WVR_TrackTiming.WhenNewPoses)
            {
                WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.NEW_POSES, OnNewPoses);
            }

            WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.INTERACTION_MODE_CHANGED, onInteractionModeChange);
            WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.SYSTEMFOCUS_CHANGED, onSystemFocusChanged);

            ptmEnabled = true;
        }
    }
Ejemplo n.º 21
0
    private bool checkConnection()
    {
#if UNITY_EDITOR
        if (Application.isEditor)
        {
            return(false);
        }
        else
#endif
        {
            WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.deviceType);
            return(_device.connected);
        }
    }
Ejemplo n.º 22
0
    // Use this for initialization
    void Start()
    {
        if (checkConnection() != connected)
        {
            connected = !connected;
        }

        if (connected)
        {
            WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.deviceType);
            onLoadController(_device.type);
        }

        WaveVR_EventSystemControllerProvider.Instance.MarkControllerLoader(deviceType, true);
    }
Ejemplo n.º 23
0
    void OnEnable()
    {
        PrintDebugLog("OnEnable");
        if (mLoadingState == LoadingState.LoadingState_LOADING)
        {
            deleteChild("RenderModel doesn't expect model is in loading, delete all children");
        }

        if (WhichHand == ControllerHand.Controller_Dominant)
        {
            deviceType   = WaveVR_Controller.EDeviceType.Dominant;
            modelSpecify = ModelSpecify.MS_Dominant;
        }
        else
        {
            deviceType   = WaveVR_Controller.EDeviceType.NonDominant;
            modelSpecify = ModelSpecify.MS_NonDominant;
        }

        connected = checkConnection();

        if (connected)
        {
            WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.deviceType);

            if (mLoadingState == LoadingState.LoadingState_LOADED)
            {
                if (isRenderModelNameSameAsPrevious())
                {
                    PrintDebugLog("OnEnable - Controller connected, model was loaded!");
                }
                else
                {
                    deleteChild("Controller load when OnEnable, render model is different!");
                    onLoadController(_device.type);
                }
            }
            else
            {
                PrintDebugLog("Controller load when OnEnable!");
                onLoadController(_device.type);
            }
        }

        WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.DEVICE_CONNECTED, onDeviceConnected);
        WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.OEM_CONFIG_CHANGED, onOEMConfigChanged);
    }
Ejemplo n.º 24
0
    void Update()
    {
        if (timing == WVR_TrackTiming.WhenNewPoses)
        {
            return;
        }
        if (WaveVR.Instance == null)
        {
            return;
        }

        WaveVR.Device device = WaveVR.Instance.getDeviceByType(this.type);
        if (device != null && device.connected)
        {
            updatePose(device.pose, device.rigidTransform);
        }
    }
    void Update()
    {
        mFPS = 1.0f / Time.deltaTime;
        if (TrackTiming == WVR_TrackTiming.WhenNewPoses)
        {
            return;
        }
        if (WaveVR.Instance == null)
        {
            return;
        }

        WaveVR.Device device = WaveVR.Instance.getDeviceByType(this.Type);
        if (device.connected)
        {
            updatePose(device.pose, device.rigidTransform);
        }
    }
Ejemplo n.º 26
0
    // Use this for initialization
    void Start()
    {
        wfs = new WaitForSeconds(1.0f);
        loadedAssetBundle.Clear();
        if (checkConnection() != connected)
        {
            connected = !connected;
        }

        if (connected)
        {
            WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.deviceType);
            onLoadController(_device.type);
        }

        WaveVR_EventSystemControllerProvider.Instance.MarkControllerLoader(deviceType, true);
        PrintDebugLog("start a coroutine to check connection and render model name periodly");
        StartCoroutine(checkRenderModelAndDelete());
    }
    private void onDeviceRoleChanged(params object[] args)
    {
        if (WaveVR.Instance != null)
        {
            WaveVR.Device _rdev = WaveVR.Instance.getDeviceByType(WVR_DeviceType.WVR_DeviceType_Controller_Right);
            if (_rdev != null)
            {
                this.rConnected = _rdev.connected;
            }
            WaveVR.Device _ldev = WaveVR.Instance.getDeviceByType(WVR_DeviceType.WVR_DeviceType_Controller_Left);
            if (_ldev != null)
            {
                this.lConnected = _ldev.connected;
            }

            this.connectionUpdated = true;
        }
        PrintDebugLog("onDeviceRoleChanged() rConnected: " + this.rConnected + ", lConnected: " + this.lConnected);
    }
    void Update()
    {
        if (timing == WVR_TrackTiming.WhenNewPoses)
        {
            return;
        }
        if (!WaveVR.Instance.Initialized)
        {
            return;
        }

        WaveVR.Device device = WaveVR.Instance.getDeviceByType(this.type);
        if (device.connected)
        {
            wvr_pose   = device.pose;
            rigid_pose = device.rigidTransform;
        }

        updatePose(wvr_pose, rigid_pose);
    }
Ejemplo n.º 29
0
    /// if device connected, get new pose, then update new position and rotation of transform
    private void OnNewPoses(params object[] args)
    {
#if UNITY_EDITOR
        if (Application.isEditor && !WaveVR.Instance.isSimulatorOn)
        {
            WVR_DeviceType _type  = WaveVR_Controller.Input(this.type).DeviceType;
            var            system = WaveVR_PoseSimulator.Instance;
            system.GetTransform(_type, ref wvr_pose, ref rigid_pose);
            updatePose(wvr_pose, rigid_pose);
        }
        else
#endif
        {
            WaveVR.Device _device = WaveVR.Instance.getDeviceByType(this.type);
            if (_device.connected)
            {
                updatePose(_device.pose, _device.rigidTransform);
            }
        }
    }
    private void onDeviceConnected(params object[] args)
    {
        WVR_DeviceType _type      = (WVR_DeviceType)args [0];
        bool           _connected = (bool)args [1];

        PrintDebugLog("onDeviceConnected() device " + _type + " is " + (_connected ? "connected." : "disconnected.") + ", left-handed? " + WaveVR_Controller.IsLeftHanded);

        WaveVR.Device _rdev = WaveVR.Instance.getDeviceByType(WVR_DeviceType.WVR_DeviceType_Controller_Right);
        WaveVR.Device _ldev = WaveVR.Instance.getDeviceByType(WVR_DeviceType.WVR_DeviceType_Controller_Left);

        if (_type == _rdev.type)
        {
            this.rConnected = _rdev.connected;
            PrintDebugLog("onDeviceConnected() rConnected: " + this.rConnected);
        }
        if (_type == _ldev.type)
        {
            this.lConnected = _ldev.connected;
            PrintDebugLog("onDeviceConnected() lConnected: " + this.lConnected);
        }
    }