Please Select Your Location
Australia
Österreich
België
Canada
Canada - Français
中国
Česká republika
Denmark
Deutschland
France
HongKong
Iceland
Ireland
Italia
日本
Korea
Latvija
Lietuva
Lëtzebuerg
Malta
المملكة العربية السعودية (Arabic)
Nederland
New Zealand
Norge
Polska
Portugal
Russia
Saudi Arabia
Southeast Asia
España
Suisse
Suomi
Sverige
台灣
Ukraine
United Kingdom
United States
Please Select Your Location
België
Česká republika
Denmark
Iceland
Ireland
Italia
Latvija
Lietuva
Lëtzebuerg
Malta
Nederland
Norge
Polska
Portugal
España
Suisse
Suomi
Sverige

Plane Detection

Supported Platforms and Devices

Platform Headset Supported Plugin Version
PC PC Streaming Focus 3/XR Elite/Focus Vision X
Pure PC Vive Cosmos X
Vive Pro series X
AIO Focus 3/XR Elite/Focus Vision V 2.3.0 or above

Specification

VIVE OpenXR Unity plugin supports Plane Detection VIVE XR PlaneDetection which depends on the OpenXR feature group.

This chapter dives into creating immersive experiences with the Plane Detection feature. We'll explore its use within the Plane Detection extensions.

Environment Settings

Go to Settings > Boundary > Mixed Reality > Reset Walls, and define the walls before using plane detection. The scripts are located in Packages VIVE OpenXR Plugin > Runtime > Toolkits > PlaneDetection.

Enable the PlaneDetection feature. In Edit > Project Settings > XR Plug-in Management > OpenXR, enable the VIVE XR PlaneDetection feature.

The feature depend on HTC XR Elite v1.0.999.644 or newer ROM.

Golden Sample

The Sample at Asset > VIVE > OpenXR > > Samples > PlaneDetection.

How to use Plane Detection

You can refer to the script PlaneDetectionTestHandle.cs.

1. Check if the Plane DetectionManager supports.

    if (!PlaneDetectionManager.IsSupported())
    {
        yield break;
    }

2. Creating a Plane Detector.

    var pd = PlaneDetectionManager.CreatePlaneDetector();
    if (pd == null)
    {
        yield break;
    }

3. Start detecting planes using the Plane Detector.

Check the status of the Plane Detector. If the status is "Completed", proceed to the next step. If the status is "Pending", continue waiting. If the status is anything else, stop the detection.

    pd.BeginPlaneDetection();
    yield return null;

    var state = pd.GetPlaneDetectionState();
    bool isDone = false;
    time = 0;
    while (isDone)
    {
        switch (state)
        {
            case VivePlaneDetection.XrPlaneDetectionStateEXT.DONE_EXT:
                Debug.Log("GetAllPlanes() state: " + state);
                isDone = true;
                break;
            case VivePlaneDetection.XrPlaneDetectionStateEXT.PENDING_EXT:
                if (time + 0.5f > Time.unscaledTime)
                {
                    time = Time.unscaledTime;
                    Debug.Log("GetAllPlanes() state: " + state);
                }
                yield return null;
                continue;
            case VivePlaneDetection.XrPlaneDetectionStateEXT.NONE_EXT:
            case VivePlaneDetection.XrPlaneDetectionStateEXT.FATAL_EXT:
            case VivePlaneDetection.XrPlaneDetectionStateEXT.ERROR_EXT:
                Debug.Log("GetAllPlanes() state: " + state);
                PlaneDetectionManager.DestroyPlaneDetector(pd);
                detectPlaneButton.interactable = true;
                yield break;
        }
        yield return null;
        state = pd.GetPlaneDetectionState();
    }

4. Get the detected plane information from the Plane Detector.

The Plane Detector Location object contains the plane's size, pose, and some raw data. Usually, only the size and pose are used. Use the planeID from Plane Detector Location to retrieve the Plane object. The Plane object contains the parsed Vertex, Index, UV, and original Vertex.

    List<PlaneDetectorLocation> locations;
    if (pd.GetPlaneDetections(out locations) != XrResult.XR_SUCCESS)
    {
        yield break;
    }

    foreach (var location in locations)
    {
        PlaneDetection.Plane plane = pd.GetPlane(location.planeId);
    }

5. Finally, release resource by API DestroyPlaneDetector.

    PlaneDetectionManager.DestroyPlaneDetector(pd);

See Also

Plane Detection extension.