WVR_EnumerateSpatialAnchors

WVR_EXPORT WVR_Result WVR_EnumerateSpatialAnchors(uint32_t anchorCapacityInput, uint32_t * anchorCountOutput, WVR_SpatialAnchor * anchors)

Function is used to enumerate spatial anchors.

This is two calls API. Developers should call this API with the value of anchorCapacityInput equals to 0 to retrieve the size of anchors from anchorCountOutput. Then developers allocate the array of WVR_SpatialAnchor handles and assign the anchorCapacityInput and call the API in the second time. Then runtime will fill the handle anchors array.

Note: Since there is a time gap between the first and the second calls, developers should verify the anchorCountOutput when retrieving the data that filled by runtime during the second time.

Version
API Level 11
Parameters
  • anchorCapacityInput: the capacity of the anchor array, or 0 to indicate a request to retrieve the required capacity.
  • anchorCountOutput: a pointer to the count of anchors written, or a pointer to the required capacity in the case that anchorCapacityInput is insufficient.
  • anchors: a pointer to an array of WVR_SpatialAnchor handles, but can be NULL if anchorCapacityInput is 0.
Return Value
  • WVR_Success: Enumerate spatial anchors successfully.
  • others: WVR_Result mean failure.

How to use

Sample function:

#include <wvr/wvr_scene.h>
#include <wvr/wvr_anchor.h>

if (WVR_StartScene() == WVR_Success) {
    // WVR_EnumerateSpatialAnchors
    uint32_t output = 0;
    if (WVR_EnumerateSpatialAnchors(0, &output, nullptr) == WVR_Success) {
        uint32_t input = output;
        auto anchors = (WVR_SpatialAnchor*)malloc(sizeof(WVR_SpatialAnchor)*(input));
        if (WVR_EnumerateSpatialAnchors(input, &output, anchors) == WVR_Success) {
            // enumerate all spatial anchors successfully
            // get the valid spatial anchors data
            uint32_t size = input<=output?input:output;
            for (int i=0; i<size; i++) {
                // ...
            }

        }
    }
    WVR_StopScene();
} else {
    // start scene failed!
}