Search Unity

Get VR room-scale bounds w/ native Unity

Discussion in 'VR' started by plmx, May 14, 2019.

  1. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    Hi,

    is there a way to get the currently set chaperone/guardian bounds (preferably in Unity units) from both SteamVR and Oculus using only native Unity code? Something in the XR namespace, maybe? I was not able to find it :-(

    Philip
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,442
    at least in steamvr there is SteamVR/Scripts/SteamVR_PlayArea.cs
    which seems to do some kind of mesh bounds from OpenVR.Chaperone.GetPlayAreaRect?

    havent tested that what it actually returns..
     
  3. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    Both the SteamVR and the Oculus plugins support getting the play area size; however, my question was/is about getting said size using only Unity API.
     
  4. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    I know we have access to it natively, but I don't see any developer APIs for it. I want to get that in for 2019.3, it really should be available without plugins.
     
  5. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    Thanks for the honest answer, and it would be totally great to have that. I keep my fingers crossed, having it in 2019 would be perfect.
     
  6. MrNorel

    MrNorel

    Joined:
    Aug 6, 2019
    Posts:
    5
    Hi,
    Is there any update on this point ?
    It would be very helpful.
    best,
    Norel
     
    IS_Twyker likes this.
  7. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    Kenthria11, ROBYER1 and hippocoder like this.
  8. Jakob

    Jakob

    Joined:
    Sep 29, 2011
    Posts:
    42
    Is there a example for this? And how to use it?
     
  9. MrNorel

    MrNorel

    Joined:
    Aug 6, 2019
    Posts:
    5
    Thanks a lot StayTalm !

    This is the way I managed to use this function :
    - Stopped using Legacy XR (Project Settings > Player > XR)
    - Started using XR Management package, as described here
    - Placed TrackedPoseDrivers on cameras since they are no longed added automatically
    - Used this code :
    Code (CSharp):
    1. List<InputDevice> inputDevices = new List<InputDevice>();
    2. InputDevices.GetDevicesWithRole(InputDeviceRole.Generic, inputDevices);
    3. InputDevice hMDDevice = inputDevices[0];
    4. XRInputSubsystem XRIS = hMDDevice.subsystem;
    5. List<Vector3> boundaryPoints = new List<Vector3>();
    6. XRIS.TryGetBoundaryPoints(boundaryPoints);
    And I get access to my Guardian boudaries, without using OVRManager, which is great.

    However, in the headset, the image is only displayed on left eye (right eye is blue). I couldn't manage to fix it, even by using Single Pass Rendering.
    The display also seems significatively slower than before.
    Any hints on how I could solve this ?

    I'm using an Oculus Rift S on Windows, with Unity 2019.3.0f1, and rendering with Universal RP.

    Best,
    Norel
     
  10. ian_unity431

    ian_unity431

    Joined:
    Oct 12, 2018
    Posts:
    10
    I found that in 2019.3.0f5 I had to use the "3D" pipeline. When I used Universal RP with the XR Managment system, it only rendered in the left eye of my Oculus Quest. From what I could find, it seems like the Universal RP isn't quite ready yet for VR development.

    Bonus: check out the XR Managment Example repo Unity is developing. you might find it useful.
    https://github.com/Unity-Technologies/XR-Interaction-Toolkit-Examples
     
  11. alexchesser

    alexchesser

    Joined:
    Sep 15, 2017
    Posts:
    147
    Confirmed. the One-eye bug is in URP 7.1.8 and will be fixed in 7.2.0 which was supposed to release two days ago, but they had a regression in QA so it'll probably be out next week sometime.
     
  12. Henrikplayer

    Henrikplayer

    Joined:
    Jun 23, 2013
    Posts:
    1
    Is there a way to get this to work with Oculus Quest via Link Cable (or Wireless via Virtual Desktop).
    I am trying to make a large roomscale application.
    The Quast Guardian System is always correct. But each Time i start the Experience the Player gets a random Position and Rotation. So I want to use the Guarding System as referenz to Calibrate the Player. But when I try to get the Boundarypoints the List is always empty.
     
    IS_Twyker and throzen like this.
  13. throzen

    throzen

    Joined:
    Jun 11, 2015
    Posts:
    6
    I have the same Problem. Also Quest, always getting an empty list. I detailed it in another thread, so I'm posting here too so both threads are cross linked, just in case ^^
    (https://forum.unity.com/threads/can-we-reuse-user-s-vr-boundaries.818331/#post-5558206)

    In your case, have you tried it with the "XRInputSubsystem.TryRecenter" after your application starts?
     
  14. miik2

    miik2

    Joined:
    Aug 23, 2018
    Posts:
    5
    hey guys, you can fix your rendering prob with updating the ur pipeline to 7.2.1 - that works for me. But unfortunately I didn´t get the boundary points, list is always empty. Do you have any suggestions?
     
  15. koniouchine

    koniouchine

    Joined:
    Mar 3, 2018
    Posts:
    5
    I had success with the following method
    Code (CSharp):
    1. public GameObject wallMarker;
    2. //Check if the boundary is configured
    3. bool configured = OVRManager.boundary.GetConfigured();
    4.         if (configured)
    5.         {
    6.             //Grab all the boundary points. Setting BoundaryType to OuterBoundary is necessary
    7.             Vector3[] boundaryPoints = OVRManager.boundary.GetGeometry(OVRBoundary.BoundaryType.OuterBoundary);
    8.        
    9.              //Generate a bunch of tall thin cubes to mark the outline
    10.             foreach (Vector3 pos in boundaryPoints)
    11.             {      
    12.                 Instantiate(wallMarker, pos, Quaternion.identity);
    13.             }
    14.         }
    Edit: This will obviously only work for Oculus
     
    Last edited: Mar 26, 2020
  16. Iron-Warrior

    Iron-Warrior

    Joined:
    Nov 3, 2009
    Posts:
    838
    Has anyone tried getting the boundary with the OpenVR plugin? Using the following code:

    Code (CSharp):
    1. var input = XRGeneralSettings.Instance.Manager.activeLoader.GetLoadedSubsystem<XRInputSubsystem>();
    2. List<Vector3> boundaryPoints = new List<Vector3>();
    3. if (input.TryGetBoundaryPoints(boundaryPoints))
    4. {
    5.     Debug.Log(boundaryPoints.Count);
    6. }
    TryGetBoundaryPoints returns true, but does not populate the list of points. When running with the Oculus loader, it does correctly populate the points in the correct positions.
     
  17. Cazforshort

    Cazforshort

    Joined:
    Feb 22, 2016
    Posts:
    16
    I am seeing the same behavior on my end. Nothing fails, but always returns and empty list.

    Since I need to use OpenXR for other things I can't switch to OVR. Were you able to fix it?
     
    IS_Twyker likes this.
  18. IS_Twyker

    IS_Twyker

    Joined:
    Sep 6, 2021
    Posts:
    35
    Any updates on this @Cazforshort @Iron-Warrior ? :/
     
  19. eisclimber

    eisclimber

    Joined:
    Feb 23, 2022
    Posts:
    1
    For me starting the XRInputSubsystem did the trick, as it turned out it was (somehow) not running. Doing so will automatically draw the bounds of the play area and recenter the XRRig in the play area:

    Code (CSharp):
    1. var input =
    2. List<XRInputSubsystem> inputSubsystems = new List<XRInputSubsystem>();
    3.         SubsystemManager.GetInstances<XRInputSubsystem>(inputSubsystems);
    4.  
    5.         if (inputSubsystems.Count > 0)
    6.         {
    7.             XRInputSubsystem inputSubsystem = inputSubsystems[0];
    8.             if (!inputSubsystem.running)
    9.             {
    10.                 // Start the subsystem if not started yet
    11.                 inputSubsystem.Start();
    12.             }
    13.             List<Vector3> boundaryPoints = new List<Vector3>();
    14.             if (inputSubsystem.TryGetBoundaryPoints(boundaryPoints))
    15.             {
    16.                 Debug.Log(boundaryPoints.Count);
    17.             }
    18.         }
    19.  
    P.S.: If you only want access the points you can stop the subsystem and reset the position and rotation of your Rig afterwards.
     
    laurentlavigne likes this.