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; } }
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); }
void Update() { chaperone.GetPlayAreaRect(ref playArea); chaperoneSetup.GetLiveCollisionBoundsInfo(out pCollisionQuadsBuffer1); chaperoneSetup.GetWorkingCollisionBoundsInfo(out pCollisionQuadsBuffer2); Debug.Log(" Working Col bounds: " + pCollisionQuadsBuffer2.Length.ToString()); GetCollisionBoundsMesh(); //chaperoneSetup.GetWorkingStandingZeroPoseToRawTrackingPose(ref pmatStandingZeroPoseToRawTrackingPose); }
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); }
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); }