WVR_GetSceneObjects¶
-
WVR_EXPORT WVR_Result WVR_GetSceneObjects(uint32_t objectCapacityInput, uint32_t * objectCountOutput, WVR_PoseOriginModel originModel, WVR_SceneObject * objects)
Function is used to retrieve scene objects.
This is two calls API. Developers should call this API with the value of objectCapacityInput equals to 0 to retrieve the size of objects from objectCountOutput. Then developers allocate the array of WVR_SceneObject data and assign the objectCapacityInput and call the API in the second time. Then runtime will fill the WVR_SceneObject array. Note that only WVR_PoseOriginModel_OriginOnHead and WVR_PoseOriginModel_OriginOnGround cases are supported in originModel.
- Version
- API Level 16
- Parameters
objectCapacityInput
: the capacity of the objects array, or 0 to indicate a request to retrieve the required capacity.objectCountOutput
: a pointer to the count of objects written, or a pointer to the required capacity in the case that objectCapacityInput is insufficient.originModel
: Only WVR_PoseOriginModel_OriginOnHead and WVR_PoseOriginModel_OriginOnGround are supported, refer to WVR_PoseOriginModel.objects
: An array of WVR_SceneObject will be filled by the runtime.
- Return Value
WVR_Success
: Get scene objects 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_3dObject) == WVR_Success) {
WVR_ScenePerceptionState state;
if (WVR_GetScenePerceptionState(WVR_ScenePerceptionTarget_3dObject, &state) == WVR_SUCCESS) {
// wait until state is WVR_ScenePerceptionState_Completed
if (state == WVR_ScenePerceptionState_Completed) {
// Start scene perception with WVR_ScenePerceptionTarget_3dObject successfully and get the state as completed.
// Developers can call WVR_GetSceneObjects to get scene object data
uint32_t sceneCount = 0;
WVR_SceneObject *sceneObjects;
if (WVR_GetSceneObjects(nullptr, 0, &sceneCount, WVR_PoseOriginModel_OriginOnHead, nullptr) == WVR_Success) {
sceneObjects = (WVR_SceneObject*)malloc(sizeof(WVR_SceneObject)*sceneCount);
if (WVR_GetSceneObjects(nullptr, sceneCount, &sceneCount, WVR_PoseOriginModel_OriginOnHead, sceneObjects) == WVR_Success) {
// get scene objects data successfully
}
}
}
}
} else {
// start perception with WVR_ScenePerceptionTarget_3dObject failed
}
// ...
WVR_StopScenePerception(WVR_ScenePerceptionTarget_3dObject);
WVR_StopScene();
} else {
// start scene failed!
}