This article describes the C++ API for State-Based Model Targets.
See State-Based Model Targets in Unity for a guide using the Unity Editor and C# API.
Native API
Set up State-Based Model Targets in C++ by configuring a ModelTargetObserver
. See the Model Target API Overview for creating and managing Model Targets.
Get the observation status and status info of the currently active Model Target state using vuModelTargetObservationGetStateInfo()
:
123CopyVuObservation *observation = nullptr;
VuModelTargetObservationStateInfo stateInfo;
vuModelTargetObservationGetStateInfo(observation, &stateInfo);
Get the list of available states of a Model Target:
12345678910111213141516171819202122CopyVuObserver *observer;
int listSize;
// Create state info list
VuModelTargetStateInfoList *list = nullptr;
vuModelTargetStateInfoListCreate(&list);
// Get and parse the state list from the Model Target Observer
vuModelTargetObserverGetAvailableStateInfos(observer, list);
// Get the number of elements in the state info list
vuModelTargetStateInfoListGetSize(list, &listSize);
for (auto i = 0; i < listSize; i++)
{
VuModelTargetStateInfo stateInfo;
vuModelTargetStateInfoListGetElement(list, i, &stateInfo);
if(strlen(stateInfo.stateName) > 0)
{
// Do something
}
}
Query the active state:
123Copy// Get the currently active state
const char* activeStateName;
vuModelTargetObserverGetActiveStateName(observer, &activeStateName);
Set the Model Target Observer to a specific state by state name:
1234Copy// Set the active Model Target state. This call should be followed by
// vuGuideViewGetImage() to update the Guide View, if used
const char *stateName = "stateName";
vuModelTargetObserverSetActiveStateName(observer, stateName);
Destroy the state info list after use to free up memory:
1CopyvuModelTargetStateInfoListDestroy(list);