コード例 #1
0
        public void OnEnable()
        {
            if (instance != null)
            {
                Debug.LogError("More than one DpnController instance was found in your scene. "
                               + "Ensure that there is only one DpnController.");
                instance.enabled = false;
            }
            //string deviceName = "WiseVision_DayDream_Controller";
            string deviceName = null;

            if (DpnManager.peripheral == DPVRPeripheral.Flip)
            {
                deviceName = "SkyWorth_DayDream_Controller";
            }
            if (!OpenPeripheral(deviceName))
            {
                Debug.Log("Open Peripheral " + deviceName + " fails.");
                return;
            }

            instance = this;

            if (DpnManager.DPVRPointer)
            {
                raycaster             = this.gameObject.AddComponent <DpnPointerPhysicsRaycaster>();
                raycaster.raycastMode = DpnBasePointerRaycaster.RaycastMode.Camera;
                raycaster.enabled     = false;

                Pointer = Instantiate(reticlePointer);
                Pointer.SetParent(this.transform);
                Pointer.transform.localPosition = new Vector3(0.0f, 0.0f, 2.0f);
                Pointer.gameObject.SetActive(false);
            }
        }
コード例 #2
0
        public void OnEnable()
        {
            if ((int)controllerindex < 0 || (int)controllerindex > 2)
            {
                return;
            }
#if UNITY_ANDROID
            if (!OpenPeripheral(NoloDeviceName[(int)controllerindex]))
#else
            DPNP_DEVICE_TYPE type = s_deviceTypes[(int)controllerindex];
            if (!OpenPeripheral(type, 0))
#endif
            {
                Debug.Log("Open Peripheral " + NoloDeviceName[(int)controllerindex] + " fails.");
                return;
            }
            _instance[(int)controllerindex] = this;

            if (DpnManager.DPVRPointer)
            {
                raycaster             = this.gameObject.AddComponent <DpnPointerPhysicsRaycaster>();
                raycaster.raycastMode = DpnBasePointerRaycaster.RaycastMode.Camera;
                raycaster.enabled     = false;

                Pointer = Instantiate(reticlePointer);
                Pointer.SetParent(this.transform);
                Pointer.transform.localPosition = new Vector3(0.0f, 0.0f, 2.0f);
                Pointer.gameObject.SetActive(false);
            }

#if UNITY_STANDALONE_WIN
            if (peripheral != null)
            {
                int event_mask = (int)DPNP_EVENT_TYPE.DPNP_EVENT_TYPE_BASE_A_TRACK | (int)DPNP_EVENT_TYPE.DPNP_EVENT_TYPE_BASE_A_UNTRACK;
                peripheral.DpnupRegisterEventNotificationFunction(null, event_mask, IntPtr.Zero);
            }
#endif

            CheckVersion();
        }
コード例 #3
0
        public void OnEnable()
        {
            if (DpnManager.peripheral != DPVRPeripheral.Polaris)
            {
                this.gameObject.SetActive(false);
                return;
            }
            DPNP_DEVICE_TYPE type = DPNP_DEVICE_TYPE.DPNP_DEVICE_TYPE_NONE;

            switch (device_type)
            {
            case DPVRControllerType.DPVR_CONTROLLER_LEFT:
                type = DPNP_DEVICE_TYPE.DPNP_DEVICE_TYPE_LEFT_CONTROLLER;
                break;

            case DPVRControllerType.DPVR_CONTROLLER_RIGHT:
                type = DPNP_DEVICE_TYPE.DPNP_DEVICE_TYPE_RIGHT_CONTROLLER;
                break;

            case DPVRControllerType.DPVR_CONTROLLER_MR:
                type = DPNP_DEVICE_TYPE.DPNP_DEVICE_TYPE_MR_CONTROLLER;
                break;
            }
            if (!OpenPeripheral(type, device_index))
            {
                Debug.Log("Open Peripheral type: " + type.ToString() + " index:" + device_index.ToString() + " fails.");
                return;
            }

            switch (DpnManager.controllerKeyMode)
            {
            case DPVRKeyMode.DPVR:
            {
                _dpvrController = this.GetComponent <DPVR_Controller>();
                if (_dpvrController == null)
                {
                    _dpvrController = this.gameObject.AddComponent <DPVR_Controller>();
                }
                if (this.GetComponent <DPVR_STEAM_Controller>() != null)
                {
                    Destroy(this.GetComponent <DPVR_STEAM_Controller>());
                }
                break;
            }

            case DPVRKeyMode.STEAM:
            {
                _dpvrSteamController = this.GetComponent <DPVR_STEAM_Controller>();
                if (_dpvrSteamController == null)
                {
                    _dpvrSteamController = this.gameObject.AddComponent <DPVR_STEAM_Controller>();
                }
                if (this.GetComponent <DPVR_Controller>() != null)
                {
                    Destroy(this.GetComponent <DPVR_Controller>());
                }
                break;
            }
            }

            if (DpnManager.DPVRPointer)
            {
                _raycaster             = this.gameObject.AddComponent <DpnPointerPhysicsRaycaster>();
                _raycaster.raycastMode = DpnBasePointerRaycaster.RaycastMode.Camera;
                _raycaster.enabled     = false;

                _pointer = Instantiate(reticlePointer);
                _pointer.SetParent(this.transform);
                _pointer.transform.localPosition = new Vector3(0.0f, 0.0f, 2.0f);
                _pointer.gameObject.SetActive(false);
            }

            if (peripheral != null)
            {
                int event_mask = (int)DPNP_EVENT_TYPE.DPNP_EVENT_TYPE_BASE_A_TRACK
                                 | (int)DPNP_EVENT_TYPE.DPNP_EVENT_TYPE_BASE_A_UNTRACK
                                 | (int)DPNP_EVENT_TYPE.DPNP_EVENT_TYPE_BASE_B_TRACK
                                 | (int)DPNP_EVENT_TYPE.DPNP_EVENT_TYPE_BASE_B_UNTRACK;
                peripheral.DpnupRegisterEventNotificationFunction(null, event_mask, IntPtr.Zero);
            }

            EnableInternalObjects(false);
        }
コード例 #4
0
        void InitPeripheral()
        {
            if (!CameraRigInit)
            {
#if UNITY_5_3_OR_NEWER || UNITY_5
                VRsupport = UnityEngine.VR.VRSettings.enabled;
#else
                VRsupport = false;
#endif
            }
            CameraRigInit = true;
            if (!Init())
            {
                return;
            }
            base.OnEnable();
            if (_instance != this && _instance != null)
            {
                Debug.LogWarning("There is another active DpnCameraRig in a scene, set it unactive");
                _instance.gameObject.SetActive(false);
            }
            _instance = this;
            _UpdateCam(DpnManager.DeviceInfo.fov_y
                       , DpnManager.DeviceInfo.fov_x / (float)DpnManager.DeviceInfo.fov_y);

            if (DpnManager.DPVRPointer)
            {
                DpnPointerPhysicsRaycaster raycaster = _center_transform.gameObject.AddComponent <DpnPointerPhysicsRaycaster>();
                raycaster.raycastMode = DpnBasePointerRaycaster.RaycastMode.Direct;
                raycaster.enabled     = true;

                Transform Pointer = Instantiate(reticlePointer);
                Pointer.SetParent(raycaster.transform);
                Pointer.transform.localPosition = new Vector3(0.0f, 0.0f, 2.0f);
                Pointer.gameObject.SetActive(true);

                _nonePointer   = Pointer.gameObject;
                _noneRaycaster = raycaster;
            }
            _hmdPeripheral = this;
            _hmdPeripheral.EnableInternalObjects(false);

            switch (DpnManager.peripheral)
            {
            case DPVRPeripheral.Polaris:
            {
                Transform Peripheral = Instantiate(Polaris);
                Peripheral.parent = this.transform;

                _defaultPeripheral = Peripheral.GetComponent <DpnMultiControllerPeripheralPolaris>();
                _defaultPeripheral.EnableInternalObjects(false);
                break;
            }

            case DPVRPeripheral.Nolo:
            {
                Transform Peripheral = Instantiate(Nolo);
                Peripheral.parent = this.transform;

                Transform boundary = Instantiate(Boundary);
                boundary.parent = this.transform;

                _defaultPeripheral = Peripheral.GetComponent <DpnMultiControllerPeripheralNolo>();
                _defaultPeripheral.EnableInternalObjects(false);
                break;
            }

            case DPVRPeripheral.Flip:
            {
                Transform Peripheral = Instantiate(Flip);
                Peripheral.parent        = this.transform;
                Peripheral.localPosition = Vector3.zero;

                Transform controller_right = Peripheral.Find("controller(right)");
                if (controller_right == null)
                {
                    break;
                }

                _defaultPeripheral = controller_right.GetComponent <DpnDaydreamController>();
                _defaultPeripheral.EnableInternalObjects(false);

                break;
            }

            case DPVRPeripheral.None:
            {
                _defaultPeripheral = _hmdPeripheral;
                break;
            }

            default:
                break;
            }

            SetPeripheral(_defaultPeripheral);
        }