WVR_GetCurrentControllerModel¶
-
WVR_EXPORT WVR_Result WVR_GetCurrentControllerModel(WVR_DeviceType ctrlerType, WVR_CtrlerModel_t ** ctrlerModel, bool isOneBone = true)
Use this function to get the controller model for the currently connected device. If the controller model does not exist, it will return 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)ctrlerModel
: (Output) A double pointer for receiving the controller model structure. The SDK will allocate the data structure for the controller animation and write the address into ctrlModelAnimData.
- Return Value
WVR_SUCCESS
: The controller model was successfully retrieved from the currently connected device.WVR_Error_CtrlerModel_InvalidModel
: The SDK can’t get the controller model information from the connected controller device or asset.WVR_Error_CtrlerModel_DeviceDisconnected
: The SDK can’t get the controller model information since the controller you want to get is not connected.WVR_Error_CtrlerModel_Unknown
: The SDK can’t get the controller model information since the system has not yet been initialized.WVR_Error_InvalidArgument
: If ctrlerModel is nullptr or pointer in *ctrlerModel isn’t nullptr.
Struct and enumeration¶
- WVR_VertexBuffer
-
struct
WVR_VertexBuffer
¶ Vertex buffer of component in controller model.
- WVR_IndexBuffer
-
struct
WVR_IndexBuffer
¶ Index buffer of component in controller model.
- WVR_CtrlerCompInfo
-
struct
WVR_CtrlerCompInfo
¶ Controller component information.
Public Members
-
WVR_VertexBuffer_t
vertices
¶ Positions.(Size should be same with normal and tex coord buffers)
-
WVR_VertexBuffer_t
normals
¶ Normals. (Size should be same with vertices and tex coord buffers)
-
WVR_VertexBuffer_t
texCoords
¶ Texture coordinates. (Size should be same with vertex and normal buffers)
-
WVR_IndexBuffer_t
indices
¶ Face indices.
-
int32_t
texIndex
¶ Index of the texture in texture table. Default is -1.
-
float
localMat
[16]¶ Pose of this component of ctrler model space.
-
char
name
[64]¶ Name of this component.
-
bool
defaultDraw
¶ Is this component draw at begin.
-
WVR_VertexBuffer_t
- WVR_CtrlerTexBitmap
-
struct
WVR_CtrlerTexBitmap
¶ Texture information.
- WVR_TouchPadPlane
-
struct
WVR_TouchPadPlane
¶ Information about touchpad plane of controller model.
Public Members
-
WVR_Vector3f_t
u
¶ U axis of touchpad plane.
-
WVR_Vector3f_t
v
¶ V axis of touchpad plane.
-
WVR_Vector3f_t
w
¶ W axis of touchpad plane.
-
WVR_Vector3f_t
center
¶ Center of touchpad plane in controller model. Unit:(m)
-
float
floatingDistance
¶ Distance between touchpad effect and touchpad plane. Unit:(m)
-
float
radius
¶ Radius of touchpad plane. Unit:(m)
-
bool
valid
¶ Is this information simulated or load from config from device service.
-
WVR_Vector3f_t
- WVR_BatteryLevelTable
-
struct
WVR_BatteryLevelTable
¶ Information about battery levels of controller model.
- WVR_CtrlerModel
-
struct
WVR_CtrlerModel
¶ Structure about all necessary information of controller model.
Public Members
-
WVR_CtrlerCompInfoTable_t
compInfos
¶ Component information
-
WVR_CtrlerTexBitmapTable_t
bitmapInfos
¶ Texture information
-
WVR_TouchPadPlane_t
touchpadPlane
¶ Touchpad information
-
WVR_BatteryLevelTable_t
batteryLevels
¶ Battery information
-
char
name
[256]¶ Name of controller model.
-
bool
loadFromAsset
¶ Default model from asset or device.
-
WVR_CtrlerCompInfoTable_t
How to use¶
See the example below:
- Create a function for getting the render model.
std::function<void()> loadModelFunc = [this](){
if (mCachedData != nullptr) {
WVR_ReleaseControllerModel(&mCachedData); //we will clear cached data ptr to nullptr.
}
WVR_Result result = WVR_GetCurrentControllerModel(mCtrlerType, &mCachedData);
if (result == WVR_Success) {
//It represent ok, set a flag to notify graphics initialization in render thread.
}
};
- Trigger the function on another thread that doesn’t block the frame update.
//Trigger load model.
loadingThread = std::thread(loadModelFunc);
- Calculate the MVP matrix of the controller for rendering.
//MVP matrix of controller.
mvps = Projection * View * iCtrlerPose;
The full example is in the Controller class of the wvr_native_hellovr sample.