WVR_GetCurrentControllerEmitter¶
-
WVR_EXPORT WVR_Result WVR_GetCurrentControllerEmitter(WVR_DeviceType ctrlerType, float emitterPose[16])
Use this function is to get emitter information of the current controller model of the currently connected device.
The emitter information is determined from the controller model that is currently connected. If the controller model of the connected device does not exist, it will use the default model in the SDK.
Note: It is not recommended to call this function in the render thread or any thread that will block frame update.
- Version
- API Level 5
- Parameters
ctrlerType
: Device type: WVR_DeviceType_Controller_Right or WVR_DeviceType_Controller_Left.(refer to WVR_DeviceType)emitterPose
: (Output) An array of 16 elements for getting the emitter pose in the controller space (same order as the OpenGL matrix).
- Return Value
WVR_SUCCESS
: The emitter pose was successfully retrieved from the currently connected device.WVR_Error_CtrlerModel_InvalidModel
: The SDK can’t get the emitter information from the connected controller device or asset.WVR_Error_CtrlerModel_DeviceDisconnected
: The SDK can’t get the emitter information since the controller you want to get is not connected.WVR_Error_CtrlerModel_Unknown
: The SDK can’t get the emitter information since the system has not yet been initialized.
How to use¶
See the example below:
- Create a function for getting the emitter information.
std::function<void()> getEmitterFunc = [this](){
WVR_Result result = WVR_GetCurrentControllerEmitter(mCtrlerType, ep);
if (result == WVR_Success) {
mEmitterPose.set(ep);
} else {
mEmitterPose = Matrix4();
}
};
- Trigger the function on another thread that doesn’t block the frame update.
//Trigger load model.
loadingThread = std::thread(getEmitterFunc);
- Draw the controller with mEmitterPose.
//MVP matrix of controller ray. Developer can design a model that its origin is in (0,0,0) and
//the forward direction of model is -z.
mvps = Projection * View * iCtrlerPose * mEmitterPose;
The full example is in the CustomController class of the wvr_native_hellovr sample.