Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved How to get the maximum rectangular play area from boundary points?

Discussion in 'VR' started by JPMcWhiskers, Jul 29, 2021.

  1. JPMcWhiskers

    JPMcWhiskers

    Joined:
    Sep 22, 2014
    Posts:
    14
    Hello, I have a problem that I'd like to submit to this board of beautiful smart people. Hopefully someone has already come up with a solution and I can do a lil copy pasta. ...But I'm doubtful.

    For us fools trying to make a roomscale VR experience, the OpenXR spec allows us to get a clockwise series of points that represents the boundary drawn by the user. Working with the Quest, these points are oriented around the player's head (I guess). This means that in cartesian space, the points can be on an angle like in the image below.

    My question is, how can I get the largest rectangle represented by the actual boundaries (The green circles)? Getting the Max and mins results in the blue circles which is incorrect.

    I'm trying to draw a rectangular play space around the player. Am I overthinking this? Should I simply generate a mesh from the boundary points?

    Thanks!

    TheProblemWithBoundaries.png
     
  2. JPMcWhiskers

    JPMcWhiskers

    Joined:
    Sep 22, 2014
    Posts:
    14
    Alright well, whatever. I grabbed a bunch of code off of the internet, jammed it all into a single CS file, and zipped it up for you guys. Run the Calculate method with the supplied boundaries and this will spit out 4 points, a center, a size, and a rotation for a rectangle.

    You're welcome.
     

    Attached Files:

  3. JPMcWhiskers

    JPMcWhiskers

    Joined:
    Sep 22, 2014
    Posts:
    14
    Wow JP that code is a mess
     
    BuzzJive likes this.
  4. Hyperactive

    Hyperactive

    Joined:
    Aug 13, 2013
    Posts:
    13
    Sounds good, though I'd love to first know how you are getting boundary points list to populate on Quest using OpenXR. Any insight there?
     
  5. Tanya_Li

    Tanya_Li

    Unity Technologies

    Joined:
    Jun 29, 2020
    Posts:
    103
    Hey,
    You could utilize TryGetBoundaryPoints to get maximum play area rect in OpenXR. Here are some notes:
    1. in OpenXR, we actually return bound rect values - width & height obtained from xrGetReferenceSpaceBoundsRect via TryGetBoundaryPoints if you have guardian/ boundary setup in headset and boundary data is supported by runtime. We formatted it into a List<Vector3> of size 4, representing the 4 points of play space rectangle. (some platforms require to have a roomscale guardian setup)

    2. There is a known issue when using Quest with Link, the result is not correct. We already reached out to Oculus about this issue, but we don't have an ETA when it will be fixed.

    One more thing to clarify, for legacy non-openXR Oculus provider, TryGetBoundaryPoints will return a list of detailed boundary points (may including hundreds of points).

    Please let me know if you have any other questions.
     
  6. IS_Twyker

    IS_Twyker

    Joined:
    Sep 6, 2021
    Posts:
    35
    Hi @Tanya_Li !

    So the GetBoundaryPoints method actually gets the play area, if I understood this correctly?
    Is there a way to get the actual boundary points in OpenXR set up by the user via their HMD?

    Note: I'm already using the Vive Pro as Quest 2 and Focus 3 gave me problems. :)
     
  7. Tanya_Li

    Tanya_Li

    Unity Technologies

    Joined:
    Jun 29, 2020
    Posts:
    103
    You are correct. With OpenXR SDK, TryGetBoundaryPoints will return the play area rect values.
    But currently there is no way to get actual detailed boundary points as user setup in OpenXR. No OpenXR spec supported that yet.
     
    Murray_Zutari likes this.
  8. Murray_Zutari

    Murray_Zutari

    Joined:
    Jun 1, 2017
    Posts:
    45
    Hi Tanya

    I am getting the 4 boundary points of my SteamVR player bounds using TryGetBoundaryPoints but they seem to be inaccurate.The 4 boundary points that are returned to me are offset by at least a metre.

    Have you encountered this? What do you need from me to help?

    Thanks
     
  9. garrettfuselier

    garrettfuselier

    Joined:
    Jul 21, 2014
    Posts:
    7
    This issue is still happening for me as well. Almost a year later, since May 2021. The points are in the incorrect spot, and seem to change position everytime the game starts.
     
  10. IS_Twyker

    IS_Twyker

    Joined:
    Sep 6, 2021
    Posts:
    35
    Is this still the case @Tanya_Li ? We really need a way to access the boundary points via OpenXR. :/
     
  11. IS_Twyker

    IS_Twyker

    Joined:
    Sep 6, 2021
    Posts:
    35
  12. Murray_Zutari

    Murray_Zutari

    Joined:
    Jun 1, 2017
    Posts:
    45
    crickets
     
    IS_Twyker likes this.
  13. Tanya_Li

    Tanya_Li

    Unity Technologies

    Joined:
    Jun 29, 2020
    Posts:
    103
    Hey guys, sorry for replying late. We investigated this issue and just release a fix for it in our latest OpenXR release 1.5.3. Please go ahead and try this out. Let me know if there is any issues. Thanks!
    I added the release note here:

    • Fixed XRInputSubsystem.TryGetBoundaryPoints returning inaccurate values. If you have guardian/boundary setup in the headset, TryGetBoundaryPoints will return a List of size 4 representing the four vertices of the Play Area rectangle, which is centered at the origin and edges corresponding to the X and Z axes of the provided space. Not all systems or spaces may support boundaries.
     
    IS_Twyker likes this.
  14. IS_Twyker

    IS_Twyker

    Joined:
    Sep 6, 2021
    Posts:
    35
    @Tanya_Li So TryGetBoundaryPoints still returns the play area and not the boundary points? But the 4 points as well as the rotation of said play area should now be correct? Hm, I guess that's a start, but the actual boundary points would really be nice to have. :/
     
  15. IS_Twyker

    IS_Twyker

    Joined:
    Sep 6, 2021
    Posts:
    35
    Bump
    @Tanya_Li Will we ever be able to get the actual boundary points via OpenXR? :(
     
  16. nilagard

    nilagard

    Joined:
    Jan 13, 2017
    Posts:
    77
    I only know that the OVR version of this has what you need. Through OVRManager.boundary.GetGeometry(OVRBoundary.BoundaryType.OuterBoundary) but this only works for Quest afaik. Sorry for not providing the solution!
     
    IS_Twyker likes this.
  17. MikleRe

    MikleRe

    Joined:
    Jul 5, 2018
    Posts:
    1
    Hello, I was wondering if you had any way of setting X and Z axes based on the boudary box to always point at the same direction for the same boundary rectangle? Setting an axis to point at the biggest or smallest edge can easily be done but then the direction of the negative or the positive is the problem. I was wondering if this could be implemented directly into the UnityEngine.XR API if Oculus and OpenXR (Spaces and all) gives you data for it.

    I saw that the X and Z always pointed at the same edges of the boundary based on the positions indices and wanted to know if the positions order meant anything or if it was just random based on an algorithm.

    The purpose would be for a "game" with multiple user in the same physical space and would remove the trouble of calibration.

    Let me know!
     
    Last edited: Oct 25, 2023