Integrating Devices
Introduction
You can control HPTK hands with almost any device (or even animations) as long as you can script an input data provider (IDP) that translates the output of that device into something that HPTK can understand.
If you want to share your integration, it is highly recommended to package your extension and link it to HPTK's integration manager. Also it's important to include a prefab called DefaultSetup.CustomDevice so other devs can make it to work just doing drag & drop in the scene.
AbstractTsf
Input data providers work with abstract transformations (AbstractTsf).
AbstractTsf is a simple class that stores:
Position: Generic Vector3.
Rotation: Generic Quaternion.
Space: Space in which position and rotation should be applied.
LocalScale: Generic Vector3.
Input Data Provider
InputDataProvider is just a class with an UpdateData() function, called by an InputController, that is reponsible for translating input data into a list of FingerPoses.
Bone data is usually given at bone level so it's required to:
Update
InputDataProvider.bones
.Call
InputDataProvider.UpdateFingerPosesFromBones()
.
InputDataProvider is also responsible for reading or calculating tracking confidence and real user's hand size.
Bones
InputDataProvider.bones
is an array of 19 items of type AbstractTsf. Each of these items represent the transformation that InputController have to apply to each master bone of its hand.
InputDataProvider.bones
contains:
Confidence
InputDataProvider must read the platform-specific tracking confidence estimation and translate it to a value between 0 and 1.
Some devices don't provide tracking confidence but they can inform when the hand or controller is tracked or not. If this is the case, InputDataProvider must set confidence to 1 when they are being tracked and back to 0 when they are not.
Hand size
Not all devices provide a value for estimated real hand size but some of them provide bone positions. When InputDataProvider.scale
is equal to 1, DefaultAvatar hands will use their scale by default (1,1,1). On its default scale, the distance between index1 and index2 in DefaultAvatar hands is about 0.1147 meters. By knowing this, we can extrapolate hand scale by comparing this value with the distance between index1 and index2 given by the device.
If the device provides scale estimation but at a different scale, InputDataProvider should rescale this estimation.
Skeleton
The following code is as a skeleton for a new InputDataProvider:
Integration Manager
An IntegrationExtension checks, in its OnValidate() function, if it's included in the list of available extensions. This list is contained in a unique IntegrationConfiguration inside the HPTK package.
To show your integration package as available in the window HPTK/Integration Manager follow these steps:
In project window, right click and navigate to Create/HPTK/IntegrationConfigurationExtension.
Add a new item in the list of extensions to add to the Integration Manager. Add more items if needed.
Add the reference to the IntegrationConfiguration asset, which is located at path Packages/HPTK/Samples/Integrations/Integrations.
DefaultSetup Prefab
A DefaultSetup prefab must include the following tree of objects:
Platform specific objects (XRRig, CameraRig, etc.)
HPTK (singleton)
Left IDP
Right IDP
DefaultSetup prefab is properly configured if it's possible to:
Create a new empty scene.
Drag & drop DefaultSetup.CustomDevice in the scene.
Drag & drop DefaultAvatar in the scene.
Build the game for that scene.
Control DefaultAvatar with the new device successfully.
Last updated