コード例 #1
0
    void Start()
    {
        string mydoc = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

        fp = new StreamWriter(Path.Combine(mydoc, "move.csv"));

        eovru.StartOpenVR();
        fp.WriteLine("time,serial,x,y,z,vx,vy,vz,rx,ry,rz,rdx,rdy,rdz,eTrackingResult");
    }
コード例 #2
0
ファイル: AllScan.cs プロジェクト: gpsnmeajp/EasyOpenVRUtil
    void Start()
    {
        eou = new EasyOpenVRUtil();
        eou.StartOpenVR();


        uint idx = eou.GetDeviceIndexBySerialNumber(serial);

        foreach (ETrackedDeviceProperty prop in Enum.GetValues(typeof(ETrackedDeviceProperty)))
        {
            bool ok   = false;
            var  name = prop.ToString();
            bool resultBool;
            if (eou.GetPropertyBool(idx, prop, out resultBool))
            {
                log += (name + " : " + resultBool);
                ok   = true;
            }
            float resultFloat;
            if (eou.GetPropertyFloat(idx, prop, out resultFloat))
            {
                log += (name + " : " + resultFloat);
                ok   = true;
            }
            int resultInt32;
            if (eou.GetPropertyInt32(idx, prop, out resultInt32))
            {
                log += (name + " : " + resultInt32);
                ok   = true;
            }
            ulong resultUint64;
            if (eou.GetPropertyUint64(idx, prop, out resultUint64))
            {
                log += (name + " : " + resultUint64);
                ok   = true;
            }
            string resultString;
            if (eou.GetPropertyString(idx, prop, out resultString))
            {
                log += (name + " : " + resultString);
                ok   = true;
            }

            if (ok)
            {
                log += "\n";
            }
        }
        Debug.Log(log);
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Q))
        {
            Debug.Log("!");
        }
        if (Input.GetKeyDown(KeyCode.A))
        {
            Debug.Log(eou.Init());
        }
        if (Input.GetKeyDown(KeyCode.W))
        {
            Debug.Log(eou.StartOpenVR());
        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            Debug.Log(eou.TakeScreenShot("D:\\tmp\\test", "D:\\tmp\\test2"));
        }
        if (Input.GetKeyDown(KeyCode.X))
        {
            Debug.Log(eou.GetDeviceIndexBySerialNumber("LHR-72214A13"));
        }
        if (Input.GetKeyDown(KeyCode.Z))
        {
            eou.Update();
            Debug.Log(eou.PutDeviceInfoListString());
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            Debug.Log(eou.PutDeviceInfoListStringFromDeviceIndexList(eou.GetDeviceIndexListByRegisteredDeviceType("tracker")));
            Debug.Log(eou.PutDeviceInfoListStringFromDeviceIndexList(eou.GetDeviceIndexListByRenderModelName("tracker")));
        }
        if (Input.GetKeyDown(KeyCode.N))
        {
            Debug.Log(eou.TriggerHapticPulse(eou.GetLeftControllerIndex()));
            Debug.Log(eou.TriggerHapticPulse(eou.GetRightControllerIndex()));
        }
        if (Input.GetKeyDown(KeyCode.B))
        {
            Debug.Log("Controller");
            Debug.Log(eou.PutDeviceInfoListStringFromDeviceIndexList(eou.GetViveControllerIndexList()));
            Debug.Log("Tracker");
            Debug.Log(eou.PutDeviceInfoListStringFromDeviceIndexList(eou.GetViveTrackerIndexList()));
            Debug.Log("BaseStation");
            Debug.Log(eou.PutDeviceInfoListStringFromDeviceIndexList(eou.GetBaseStationIndexList()));
        }
        if (Input.GetKeyDown(KeyCode.Y))
        {
        }

        /*
         * Vector3 pos;
         * Quaternion rot;
         * eou.GetHMDPose(out pos, out rot);
         * obj.transform.position = pos;
         * obj.transform.rotation = rot;
         *
         * eou.GetPoseBySerialNumber("LHR-72214A13", out pos, out rot);
         * obj2.transform.position = pos;
         * obj2.transform.rotation = rot;
         *
         * Vector3 pos2;
         * Quaternion rot2;
         * eou.GetControllerPose(out pos, out rot, out pos2, out rot2);
         * obj3.transform.position = pos;
         * obj3.transform.rotation = rot;
         *
         * obj4.transform.position = pos2;
         * obj4.transform.rotation = rot2;
         */
    }
コード例 #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                Console.WriteLine("Loaded");
                title = this.Title;
                ManagerVersion.Text = Version;
                DriverVersion.Text  = "-";

                dispatcherTimer          = new DispatcherTimer();
                dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100);
                dispatcherTimer.Tick    += new EventHandler(GenericTimer);
                dispatcherTimer.Start();

                rnd = new Random();

                util = new EasyOpenVRUtil();
                if (!util.StartOpenVR())
                {
                    Close();
                    return;
                }

                osc = new OSC("127.0.0.1", 39571, 39570, OnBundle, OnMessage);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace, title);
                Close();
                return;
            }

            string[] args = System.Environment.GetCommandLineArgs();
            if (args.Length > 1)
            {
                if (args[1] == "install")
                {
                    InstallButton(null, null);
                    Close();
                    return;
                }
                if (args[1] == "uninstall")
                {
                    UninstallButton(null, null);
                    Close();
                    return;
                }
            }

            //セーフモードチェック
            EVRSettingsError eVRSettingsError = EVRSettingsError.None;
            bool             safemode         = OpenVR.Settings.GetBool("driver_vmt", OpenVR.k_pch_Driver_BlockedBySafemode_Bool, ref eVRSettingsError);

            if (eVRSettingsError == EVRSettingsError.None && safemode)
            {
                var result = MessageBox.Show("SteamVR runnning on safe mode and VMT has blocked.\nPlease unblock, and restart SteamVR.\n\nSteamVRがセーフモードで動作し、VMTがブロックされています。\nブロックを解除し、SteamVRを再起動してください。", title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            //Enableチェック
            eVRSettingsError = EVRSettingsError.None;
            bool enable = OpenVR.Settings.GetBool("driver_vmt", OpenVR.k_pch_Driver_Enable_Bool, ref eVRSettingsError);

            if (eVRSettingsError == EVRSettingsError.None && !enable)
            {
                var result = MessageBox.Show("VMT has disabled in Steam VR setting.\nPlease enable, and restart SteamVR.\n\nVMTはSteamVR上で無効に設定されています。\n有効にし、SteamVRを再起動してください。", title, MessageBoxButton.OK, MessageBoxImage.Error);
            }

            //デバッグのためにセーフモードを有効化
            //OpenVR.Settings.SetBool(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_EnableSafeMode, true,ref eVRSettingsError);
        }
コード例 #5
0
    void Update()
    {
        if (!eou.IsReady())
        {
            eou.StartOpenVR();
        }

        if (HMD_Offset == null || LeftHand_Offset == null || RightHand_Offset == null)
        {
            HMD_Offset       = eou.GetHMDTransform();
            LeftHand_Offset  = eou.GetLeftControllerTransform();
            RightHand_Offset = eou.GetRightControllerTransform();
        }

        eou.AutoExitOnQuit();

        _config = configManager.GetConfig();

        HMDTrans       = eou.GetHMDTransform();
        LeftHandTrans  = eou.GetLeftControllerTransform();
        RightHandTrans = eou.GetRightControllerTransform();

        eou.SetGameObjectTransform(ref HMD, HMDTrans);
        eou.SetGameObjectTransform(ref LeftHand, LeftHandTrans);
        eou.SetGameObjectTransform(ref RightHand, RightHandTrans);

        eou.SetGameObjectTransformWithOffset(ref HMD_withOffset, HMDTrans, HMD_Offset);
        eou.SetGameObjectTransformWithOffset(ref LeftHand_withOffset, LeftHandTrans, LeftHand_Offset);
        eou.SetGameObjectTransformWithOffset(ref RightHand_withOffset, RightHandTrans, RightHand_Offset);

        ulong button;

        if (isFollowRightHand)
        {
            eou.GetControllerButtonPressed(eou.GetRightControllerIndex(), out button);
        }
        else
        {
            eou.GetControllerButtonPressed(eou.GetLeftControllerIndex(), out button);
        }
        if (button != 0)
        {
            V_Chest.SetActive(false);
            V_Foot_L.SetActive(false);
            V_Foot_R.SetActive(false);
            V_Offset.SetActive(false);
        }

        if (_config.isMenuLeftHand && LeftHandTrans != null && LeftHandTrans.velocity.y < -3.5f || _config.isMenuRightHand && RightHandTrans != null && RightHandTrans.velocity.y < -3.5f)
        {
            if (!MenuManager.IsActive() && (!_config.isMenuLock || _config.MenuLockButton == 0 || _config.MenuLockButton == button))
            {
                MenuManager.Open();
            }
        }
        else if (_config.isMenuLeftHand && LeftHandTrans != null && LeftHandTrans.velocity.y > 3.5f || _config.isMenuRightHand && RightHandTrans != null && RightHandTrans.velocity.y > 3.5f)
        {
            if (MenuManager.IsActive() && (!_config.isMenuLock || _config.MenuLockButton == 0 || _config.MenuLockButton == button))
            {
                MenuManager.Close();
            }
        }
    }
コード例 #6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                Console.WriteLine("Loaded");
                title = this.Title;
                ManagerVersion.Text = Version;
                DriverVersion.Text  = " - ";

                rnd = new Random();
                osc = new OSC("127.0.0.1", 39571, 39570, OnBundle, OnMessage);

                util = new EasyOpenVRUtil();
                if (!util.StartOpenVR())
                {
                    //var result = MessageBox.Show("Steam VR not ready. Maybe not ready for HMD or Tracking system.\nStream VRが利用できません。HMDやトラッキングシステムが利用できない状態の可能性があります。", title, MessageBoxButton.OK, MessageBoxImage.Error);
                    TopErrorMessage("Steam VR not ready. Maybe not ready for HMD or Tracking system.\nStream VRが利用できません。HMDやトラッキングシステムが利用できない状態の可能性があります。\n\nPlease set requireHmd to false on SteamVR If you want to use without HMD. (Almost functions will not work.)\nHMDなしで利用したい場合は、SteamVRにてrequireHmdをfalseにして再起動してください。(殆どの機能は利用できません)");
                    //Close();
                    //タイマー起動してはいけない
                    return;
                }

                if (Environment.Is64BitOperatingSystem == false)
                {
                    TopErrorMessage("VMT works 64bit OS only.\n VMTは64bit OSでのみ動作します。");
                    //タイマー起動してはいけない
                    return;
                }

                //タイマー起動
                dispatcherTimer          = new DispatcherTimer();
                dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100);
                dispatcherTimer.Tick    += new EventHandler(GenericTimer);
                dispatcherTimer.Start();

                //セーフモードチェック
                EVRSettingsError eVRSettingsError = EVRSettingsError.None;
                bool             safemode         = OpenVR.Settings.GetBool("driver_vmt", OpenVR.k_pch_Driver_BlockedBySafemode_Bool, ref eVRSettingsError);
                if (eVRSettingsError == EVRSettingsError.None && safemode)
                {
                    //var result = MessageBox.Show("SteamVR runnning on safe mode and VMT has blocked.\nPlease unblock, and restart SteamVR.\n\nSteamVRがセーフモードで動作し、VMTがブロックされています。\nブロックを解除し、SteamVRを再起動してください。", title, MessageBoxButton.OK, MessageBoxImage.Error);
                    TopErrorMessage("SteamVR runnning on safe mode and VMT has blocked.\nPlease unblock, and restart SteamVR.\n\nSteamVRがセーフモードで動作し、VMTがブロックされています。\nブロックを解除し、SteamVRを再起動してください。");
                    return;
                }
                //Enableチェック
                eVRSettingsError = EVRSettingsError.None;
                bool enable = OpenVR.Settings.GetBool("driver_vmt", OpenVR.k_pch_Driver_Enable_Bool, ref eVRSettingsError);
                if (eVRSettingsError == EVRSettingsError.None && !enable)
                {
                    //var result = MessageBox.Show("VMT has disabled in Steam VR setting.\nPlease enable, and restart SteamVR.\n\nVMTはSteamVR上で無効に設定されています。\n有効にし、SteamVRを再起動してください。", title, MessageBoxButton.OK, MessageBoxImage.Error);
                    TopErrorMessage("VMT has disabled in Steam VR setting.\nPlease enable, and restart SteamVR.\n\nVMTはSteamVR上で無効に設定されています。\n有効にし、SteamVRを再起動してください。");
                    return;
                }
                //requireHmdチェック
                eVRSettingsError = EVRSettingsError.None;
                bool requireHmd = OpenVR.Settings.GetBool("steamvr", OpenVR.k_pch_SteamVR_RequireHmd_String, ref eVRSettingsError);
                if (eVRSettingsError == EVRSettingsError.None && !requireHmd)
                {
                    //var result = MessageBox.Show("VMT has disabled in Steam VR setting.\nPlease enable, and restart SteamVR.\n\nVMTはSteamVR上で無効に設定されています。\n有効にし、SteamVRを再起動してください。", title, MessageBoxButton.OK, MessageBoxImage.Error);
                    TopWarningMessage("Manager detected requireHmd is false on SteamVR. Some functions will not work probably.\nSteamVRにてrequireHmdがfalseに設定されています。いくつかの機能は正常に動かない可能性があります。", true);
                }

                //デバッグのためにセーフモードを有効化
                //OpenVR.Settings.SetBool(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_EnableSafeMode, true,ref eVRSettingsError);

                string[] args = System.Environment.GetCommandLineArgs();
                if (args.Length > 1)
                {
                    if (args[1] == "install")
                    {
                        InstallButton(null, null);
                        Close();
                        return;
                    }
                    if (args[1] == "uninstall")
                    {
                        UninstallButton(null, null);
                        Close();
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace, title);
                Close();
                return;
            }
        }