Exemplo n.º 1
0
    IEnumerator UpdateBounds()
    {
        GetComponent <MeshFilter>().mesh = null;        // clear existing

        var vr = SteamVR.instance;

        if (vr == null)
        {
            yield break;
        }

        var error      = HmdError.None;
        var pChaperone = OpenVR.GetGenericInterface(OpenVR.IVRChaperone_Version, ref error);

        if (pChaperone == System.IntPtr.Zero || error != HmdError.None)
        {
            yield break;
        }

        var chaperone = new CVRChaperone(pChaperone);

        while (chaperone.GetCalibrationState() != ChaperoneCalibrationState.OK)
        {
            yield return(null);
        }

        BuildMesh();
    }
        private void CreateSpaceGuardWalls()
        {
            switch (ConfigurationManager.GetConfiguration())
            {
            case ConfigurationManager.Configuration.HTC_Vive:
                CVRChaperone chaperone = OpenVR.Chaperone;
                HmdQuad_t    area      = new HmdQuad_t();
                chaperone.GetPlayAreaRect(ref area);
                CreateWall(area.vCorners0.v0, area.vCorners0.v2, area.vCorners1.v0, area.vCorners1.v2, "Wall1");
                CreateWall(area.vCorners1.v0, area.vCorners1.v2, area.vCorners2.v0, area.vCorners2.v2, "Wall2");
                CreateWall(area.vCorners2.v0, area.vCorners2.v2, area.vCorners3.v0, area.vCorners3.v2, "Wall3");
                CreateWall(area.vCorners3.v0, area.vCorners3.v2, area.vCorners0.v0, area.vCorners0.v2, "Wall4");
                CreateFloor(area.vCorners0.v0, area.vCorners0.v2, area.vCorners2.v0, area.vCorners2.v2);
                chaperone.ForceBoundsVisible(false);
                break;

            case ConfigurationManager.Configuration.MoCapRoom:
                CreateCube(2);
                break;

            default:
                if (forceSize > 0)
                {
                    CreateCube(forceSize);
                }
                break;
            }
        }
Exemplo n.º 3
0
        public override Vector3 GetPlayspaceBounds()
        {
            bool initOpenVR = (!SteamVR.active && !SteamVR.usingNativeSupport);

            if (initOpenVR)
            {
                EVRInitError error = EVRInitError.None;
                OpenVR.Init(ref error, EVRApplicationType.VRApplication_Other);
            }

            CVRChaperone chaperone = OpenVR.Chaperone;

            if (chaperone != null)
            {
                chaperone.GetPlayAreaSize(ref PlayspaceBounds.x, ref PlayspaceBounds.z);
                PlayspaceBounds.y = 1;
            }

            if (initOpenVR)
            {
                OpenVR.Shutdown();
            }

            return(PlayspaceBounds);
        }
Exemplo n.º 4
0
        public static bool GetBounds(Size size, ref HmdQuad_t pRect)
        {
            if (size == Size.Calibrated)
            {
                bool initOpenVR = (!SteamVR.active && !SteamVR.usingNativeSupport);
                if (initOpenVR)
                {
                    EVRInitError error = EVRInitError.None;
                    OpenVR.Init(ref error, EVRApplicationType.VRApplication_Other);
                }

                CVRChaperone chaperone = OpenVR.Chaperone;
                bool         success   = (chaperone != null) && chaperone.GetPlayAreaRect(ref pRect);
                if (!success)
                {
                    Debug.LogWarning("Failed to get Calibrated Play Area bounds!  Make sure you have tracking first, and that your space is calibrated.");
                }

                if (initOpenVR)
                {
                    OpenVR.Shutdown();
                }

                return(success);
            }
            else
            {
                try
                {
                    string   str = size.ToString().Substring(1);
                    string[] arr = str.Split(new char[] { 'x' }, 2);

                    // convert to half size in meters (from cm)
                    float x = float.Parse(arr[0]) / 200;
                    float z = float.Parse(arr[1]) / 200;

                    pRect.vCorners0.v0 = x;
                    pRect.vCorners0.v1 = 0;
                    pRect.vCorners0.v2 = -z;

                    pRect.vCorners1.v0 = -x;
                    pRect.vCorners1.v1 = 0;
                    pRect.vCorners1.v2 = -z;

                    pRect.vCorners2.v0 = -x;
                    pRect.vCorners2.v1 = 0;
                    pRect.vCorners2.v2 = z;

                    pRect.vCorners3.v0 = x;
                    pRect.vCorners3.v1 = 0;
                    pRect.vCorners3.v2 = z;

                    return(true);
                }
                catch { }
            }

            return(false);
        }
Exemplo n.º 5
0
 public static bool GetBounds(SteamVR_PlayArea.Size size, ref HmdQuad_t pRect)
 {
     if (size == SteamVR_PlayArea.Size.Calibrated)
     {
         bool flag = !SteamVR.active && !SteamVR.usingNativeSupport;
         if (flag)
         {
             EVRInitError evrinitError = EVRInitError.None;
             OpenVR.Init(ref evrinitError, EVRApplicationType.VRApplication_Utility);
         }
         CVRChaperone chaperone = OpenVR.Chaperone;
         bool         flag2     = chaperone != null && chaperone.GetPlayAreaRect(ref pRect);
         if (!flag2)
         {
             Debug.LogWarning("Failed to get Calibrated Play Area bounds!  Make sure you have tracking first, and that your space is calibrated.");
         }
         if (flag)
         {
             OpenVR.Shutdown();
         }
         return(flag2);
     }
     try
     {
         string   text  = size.ToString().Substring(1);
         string[] array = text.Split(new char[]
         {
             'x'
         }, 2);
         float num  = float.Parse(array[0]) / 200f;
         float num2 = float.Parse(array[1]) / 200f;
         pRect.vCorners0.v0 = num;
         pRect.vCorners0.v1 = 0f;
         pRect.vCorners0.v2 = -num2;
         pRect.vCorners1.v0 = -num;
         pRect.vCorners1.v1 = 0f;
         pRect.vCorners1.v2 = -num2;
         pRect.vCorners2.v0 = -num;
         pRect.vCorners2.v1 = 0f;
         pRect.vCorners2.v2 = num2;
         pRect.vCorners3.v0 = num;
         pRect.vCorners3.v1 = 0f;
         pRect.vCorners3.v2 = num2;
         return(true);
     }
     catch
     {
     }
     return(false);
 }
Exemplo n.º 6
0
    private IEnumerator UpdateBounds()
    {
        base.GetComponent <MeshFilter>().mesh = null;
        CVRChaperone chaperone = OpenVR.Chaperone;

        if (chaperone == null)
        {
            yield break;
        }
        while (chaperone.GetCalibrationState() != ChaperoneCalibrationState.OK)
        {
            yield return(null);
        }
        this.BuildMesh();
        yield break;
    }
Exemplo n.º 7
0
        IEnumerator UpdateBounds()
        {
            GetComponent <MeshFilter>().mesh = null; // clear existing

            CVRChaperone chaperone = OpenVR.Chaperone;

            if (chaperone == null)
            {
                yield break;
            }

            while (chaperone.GetCalibrationState() != ChaperoneCalibrationState.OK)
            {
                yield return(null);
            }

            BuildMesh();
        }
Exemplo n.º 8
0
    // Use this for initialization
    void Start()
    {
        var error = EVRInitError.None;


        var pChaperone = OpenVR.GetGenericInterface(OpenVR.IVRChaperone_Version, ref error);

        if (pChaperone == System.IntPtr.Zero || error != EVRInitError.None)
        {
            // if (!SteamVR.active)
            //   OpenVR.Shutdown();

            return;
        }


        var chaperone      = new CVRChaperone(pChaperone);
        var chaperoneSetup = new CVRChaperoneSetup(pChaperone);

        //var  pQuadsBuffer = new HmdQuad_t[];

        HmdQuad_t[] pQuadsBuffer = null;


        // //pQuadsBuffer= new HmdQuad_t[punQuadsCount];
//
        // int punQuadsCount = 10;
        // HmdQuad_t[] pqd = new HmdQuad_t[[punQuadsCount];
        bool hasBounds = chaperoneSetup.GetLiveCollisionBoundsInfo(out pQuadsBuffer);

        if (hasBounds == true)
        {
            print("YAYA");
            print(pQuadsBuffer);
        }
        else
        {
            print("NOOO");
        }
        //print( chaperone );
        //print( chaperoneSetup );
//    print( rect );
    }
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        if (OpenVR.IsHmdPresent())
        {
            CVRChaperone chap = OpenVR.Chaperone;
            float        w    = 0.0f;
            float        l    = 0.0f;
            chap.GetPlayAreaSize(ref w, ref l);
            this.transform.localScale = new Vector3(w * 0.1f, 1.0f, l * 0.1f);

            Material mat = this.gameObject.GetComponent <Renderer>().material;


            mat.mainTextureScale = new Vector2(Mathf.Round(w * 5.0f), Mathf.Round(l * 5.0f));
        }
        else
        {
            Debug.Log("Can't initialize checkered floor pattern. Starting without it.");
        }
    }
Exemplo n.º 10
0
        private IEnumerator Start()
        {
            CVRChaperone chaperone = OpenVR.Chaperone;

            if (chaperone == null)
            {
                Debug.LogWarning("Failed to get IVRChaperone interface.");
                this.initialized = true;
                yield break;
            }
            float px;
            float pz;

            for (;;)
            {
                px = 0f;
                pz = 0f;
                if (chaperone.GetPlayAreaSize(ref px, ref pz))
                {
                    break;
                }
                yield return(null);
            }
            this.initialized   = true;
            this.playAreaSizeX = px;
            this.playAreaSizeZ = pz;
            this.roomscale     = (Mathf.Max(px, pz) > 1.01f);
            Debug.LogFormat("ChaperoneInfo initialized. {2} play area {0:0.00}m x {1:0.00}m", new object[]
            {
                px,
                pz,
                (!this.roomscale) ? "Standing" : "Roomscale"
            });
            ChaperoneInfo.Initialized.Send();
            yield break;
            yield break;
        }
Exemplo n.º 11
0
        // Token: 0x060021ED RID: 8685 RVA: 0x000A7B6A File Offset: 0x000A5D6A
        private IEnumerator Start()
        {
            CVRChaperone chaperone = OpenVR.Chaperone;

            if (chaperone == null)
            {
                Debug.LogWarning("Failed to get IVRChaperone interface.");
                this.initialized = true;
                yield break;
            }
            float num;
            float num2;

            for (;;)
            {
                num  = 0f;
                num2 = 0f;
                if (chaperone.GetPlayAreaSize(ref num, ref num2))
                {
                    break;
                }
                yield return(null);
            }
            this.initialized   = true;
            this.playAreaSizeX = num;
            this.playAreaSizeZ = num2;
            this.roomscale     = (Mathf.Max(num, num2) > 1.01f);
            Debug.LogFormat("ChaperoneInfo initialized. {2} play area {0:0.00}m x {1:0.00}m", new object[]
            {
                num,
                num2,
                this.roomscale ? "Roomscale" : "Standing"
            });
            ChaperoneInfo.Initialized.Send();
            yield break;
            yield break;
        }
Exemplo n.º 12
0
    public static bool GetBounds(Size size, ref HmdQuad_t pRect)
    {
        if (size == Size.Calibrated)
        {
            var error = HmdError.None;
            if (!SteamVR.active)
            {
                OpenVR.Init(ref error, EVRApplicationType.VRApplication_Other);
                if (error != HmdError.None)
                {
                    return(false);
                }
            }

            var pChaperone = OpenVR.GetGenericInterface(OpenVR.IVRChaperone_Version, ref error);
            if (pChaperone == System.IntPtr.Zero || error != HmdError.None)
            {
                if (!SteamVR.active)
                {
                    OpenVR.Shutdown();
                }
                return(false);
            }

            var chaperone = new CVRChaperone(pChaperone);

            bool success = chaperone.GetPlayAreaRect(ref pRect);
            if (!success)
            {
                Debug.LogWarning("Failed to get Calibrated Play Area bounds!  Make sure you have tracking first, and that your space is calibrated.");
            }

            if (!SteamVR.active)
            {
                OpenVR.Shutdown();
            }

            return(success);
        }
        else
        {
            try
            {
                var str = size.ToString().Substring(1);
                var arr = str.Split(new char[] { 'x' }, 2);
                // convert to half size in meters (from cm)
                var x = float.Parse(arr[0]) / 200;
                var z = float.Parse(arr[1]) / 200;
                pRect.vCorners      = new HmdVector3_t[4];
                pRect.vCorners[0].v = new float[3] {
                    x, 0, z
                };
                pRect.vCorners[1].v = new float[3] {
                    x, 0, -z
                };
                pRect.vCorners[2].v = new float[3] {
                    -x, 0, -z
                };
                pRect.vCorners[3].v = new float[3] {
                    -x, 0, z
                };
                return(true);
            }
            catch {}
        }

        return(false);
    }
 // Use this for initialization
 void Awake()
 {
     chaperoneSetup = OpenVR.ChaperoneSetup;
     chaperone      = OpenVR.Chaperone;
 }