WVR_GetSceneMeshBuffer

WVR_EXPORT WVR_Result WVR_GetSceneMeshBuffer(uint64_t meshBufferId, WVR_PoseOriginModel originModel, WVR_SceneMeshBuffer * sceneMeshBuffer)

Function is used to retrieves the scene mesh vertex buffer and index buffer for the given scene mesh buffer identifier.

This is two calls API. Developers should call this API with the value of vertexCapacityInput/indexCapacityInput (WVR_SceneMeshBuffer) equals to 0 to retrieve the size of vertexBuffer/indexBuffer from vertexCountOutput/indexCountOutput. Then developers allocate the array of vertexBuffer/indexBuffer and call the API in the second time. Then runtime will fill these two arrays.

Note: This API may cause lots of memory copy, if you call the first time, please set the vertexCapacityInput/indexCapacityInput equals to 0, and let vertexBuffer/indexBuffer equals to nullptr, then runtime will just fill the vertexCountOutput/indexCountOutput size.

Version
API Level 11
Parameters
  • meshBufferId: the scene mesh buffer identifier
  • originModel: Only WVR_PoseOriginModel_OriginOnHead and WVR_PoseOriginModel_OriginOnGround are supported, refer to WVR_PoseOriginModel.
  • sceneMeshBuffer: the scene mesh vertex buffer and index buffer, refer to WVR_SceneMeshBuffer
Return Value
  • WVR_Success: Get scene mesh buffer successfully.
  • others: WVR_Result mean failure.

How to use

Sample function:

#include <wvr/wvr_scene.h>

if (WVR_StartScene() == WVR_Success) {
    if (WVR_StartScenePerception(WVR_ScenePerceptionTarget_SceneMesh) == WVR_Success) {
        WVR_ScenePerceptionState state;
        if (WVR_GetScenePerceptionState(WVR_ScenePerceptionTarget_SceneMesh, &state) == WVR_Success) {
            if (state == WVR_ScenePerceptionState_Completed) {
                // Start scene perception with WVR_ScenePerceptionTarget_SceneMesh successfully and get the state as completed.
                // Developers can call WVR_GetSceneMeshes to get scene meshes array
                uint32_t sceneCount = 0;
                WVR_SceneMesh *sceneMesh;
                if (WVR_GetSceneMeshes(WVR_SceneMeshType_VisualMesh, 0, &sceneCount, nullptr) == WVR_Success) {
                    sceneMesh = (WVR_SceneMesh*)malloc(sizeof(WVR_SceneMesh)*sceneCount);
                    if (WVR_GetSceneMeshes(WVR_SceneMeshType_VisualMesh, sceneCount, &sceneCount, sceneMesh) == WVR_Success) {
                       // get scene mesh successfully

                       // get scene mesh identifier(sceneMesh[0]) to retrieve scene mesh vertex buffer and index buffer
                       WVR_SceneMeshBuffer buffer = {0, 0, nullptr, 0, 0, nullptr};
                       if (WVR_GetSceneMeshBuffer(sceneMesh[0], &buffer) == WVR_Success) {
                           auto vertexBuffer = (WVR_Vector3f*)malloc(sizeof(WVR_Vector3f)*(buffer.vertexCountOutput));
                           auto indexBuffer = (uint32_t*)malloc(sizeof(uint32_t)*(buffer.indexCountOutput));
                           WVR_SceneMeshBuffer buffer1 = {buffer.vertexCountOutput, buffer.vertexCountOutput, vertexBuffer, buffer.indexCountOutput, buffer.indexCountOutput, indexBuffer};
                           if (WVR_GetSceneMeshBuffer(sceneMesh[0], &buffer1) == WVR_Success) {
                               // get sceneMesh[0] buffer data stucture successfully
                           }
                       }
                    }
                }

            }
        }
    } else {
        // start perception with WVR_ScenePerceptionTarget_SceneMesh failed
    }
    // ...
    WVR_StopScenePerception(WVR_ScenePerceptionTarget_SceneMesh);
    WVR_StopScene();
} else {
    // start scene failed!
}