public void Session_TestBoundaryPoint() { IntPtr sessionPtr = CreateSession(); Assert.AreNotEqual(IntPtr.Zero, sessionPtr); var boundaryTestResult = new BoundaryTestResult(); Result result = OVR.TestBoundaryPoint(sessionPtr, new Vector3f(1, 1, 1), BoundaryType.PlayArea, ref boundaryTestResult); Assert.IsFalse(result == Result.Success_BoundaryInvalid, "Boundaries are not set on Oculus. Boundaries require Oculus Touch. Please run a full setup in Oculus settings to set up boundaries before runing the test."); Assert.IsTrue(result >= Result.Success, "Failed to call TestBoundaryPoint"); if (result != Result.Success_DeviceUnavailable) { // Check that we get a valid data back (we assume the values bigger than 10 meters are not valid) Assert.IsTrue(boundaryTestResult.ClosestDistance > -10 && boundaryTestResult.ClosestDistance < 10, "Invalid ClosestDistance"); Assert.IsTrue(-10 < boundaryTestResult.ClosestPoint.X && boundaryTestResult.ClosestPoint.X < 10 && -10 < boundaryTestResult.ClosestPoint.Y && boundaryTestResult.ClosestPoint.Y < 10 && -10 < boundaryTestResult.ClosestPoint.Z && boundaryTestResult.ClosestPoint.Z < 10, "Invalid ClosestPoint"); Assert.IsTrue(boundaryTestResult.ClosestPointNormal.X + boundaryTestResult.ClosestPointNormal.Y + boundaryTestResult.ClosestPointNormal.Z < 0.01, // should be 1 "Invalid ClosestPointNormal"); } }
public virtual void CheckBounds() { // if (m_TrackerHandle == -1 || XDevicePlugin.GetInt(m_TrackerHandle, XDevicePlugin.kField_ConnectionStateInt, 0) != (int)DeviceConnectionState.Connected ) { return; } // BoundaryTestResult hitInfo = new BoundaryTestResult(); Vector3 position = Vector3.zero; float minDistance = float.MaxValue; int intRet; for (int i = 0, imax = trackedNodes.Length; i < imax; ++i) { intRet = NativeMethods.XDeviceTestNode(m_TrackerHandle, trackedNodes[i], ref hitInfo); if (intRet >= 0) { if (intRet == 0) // False => outside { if (hitInfo.distance != float.MaxValue && hitInfo.distance > 0.0f) { hitInfo.distance *= -1; } } if (hitInfo.distance < minDistance) { minDistance = hitInfo.distance; } } } if (m_PlayArea != null) { float alpha = 1.0f - Mathf.Clamp01(minDistance / warningDistance); // m_PlayArea.groundAlpha = m_GroundAlpha; m_PlayArea.wallAlpha = alpha * m_WallAlpha; m_PlayArea.planeAlpha = alpha * m_PlaneAlpha; } }
public static extern int XDeviceTestNode(int which, int node, ref BoundaryTestResult result);
public static extern Result ovr_TestBoundaryPoint(ovrSession session, ref Vector3 point, BoundaryType singleboundaryType, ref BoundaryTestResult outTestResult);
public static extern Result ovr_TestBoundary(ovrSession session, TrackedDeviceType deviceBitmask, BoundaryType boundaryType, ref BoundaryTestResult outTestResult);
public static extern bool Boundary_HitTest(System.IntPtr boundary, float x, float y, float z, out BoundaryTestResult result);
public virtual void UpdatePlayArea() { // TODO : if (m_PlayAreaGround == null) { m_PlayAreaGround = m_PlayArea.FindChild("_Ground"); } if (m_PlayAreaWall == null) { m_PlayAreaWall = m_PlayArea.FindChild("_Walls"); } // Vector3 position = Vector3.zero; if (m_PlayAreaGround != null) { position = m_PlayAreaGround.position; position.y = 0.0f; m_PlayAreaGround.position = position; } if (m_PlayAreaWall != null) { position = m_PlayAreaWall.localPosition; position.y = playAreaOffsetY - m_PlayAreaRenderer.height; m_PlayAreaWall.localPosition = position; } // BoundaryTestResult hitInfo = new BoundaryTestResult(); float minDistance = float.MaxValue; for (int i = 0, imax = s_TrackedNodes.Length; i < imax; ++i) { if (Exists(s_TrackedNodes[i])) { // position = GetPosition(s_TrackedNodes[i]); position = m_PlayArea.InverseTransformPoint(trackingSpace.TransformPoint(position)); // if (NativeMethods.Boundary_HitTest(m_BoundaryPtr, position[0], position[1], -position[2], out hitInfo )) { // TODO : //hitInfo.distance=-1.0f; } else { if (hitInfo.distance > 0.0f) { hitInfo.distance *= -1; } } if (hitInfo.distance < minDistance) { minDistance = hitInfo.distance; } } } if (m_PlayAreaRenderer != null) { float alpha = 1.0f - Mathf.Clamp01(minDistance / warningDistance); // m_PlayAreaRenderer.groundAlpha = 1.0f; m_PlayAreaRenderer.wallAlpha = alpha * 1.0f; } }