Skip to content

State-Based Model Targets in Native

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():

1
2
3
VuObservation *observation = nullptr;
VuModelTargetObservationStateInfo stateInfo;
vuModelTargetObservationGetStateInfo(observation, &stateInfo);

Get the list of available states of a Model Target:

VuObserver *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:

1
2
3
// Get the currently active state
const char* activeStateName;
vuModelTargetObserverGetActiveStateName(observer, &activeStateName);

Set the Model Target Observer to a specific state by state name:

1
2
3
4
// 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:

vuModelTargetStateInfoListDestroy(list);

Learn More

State-Based Model Targets

Illustration Files and Process Plans for State-Based Model Targets

Generate State-Based Model Targets

State-Based Model Targets in Unity