Vive Tracker
Vive Tracker
Vive Tracker
Vive Tracker
Developer Guidelines
Developer Guidelines
Developer Guidelines
Developer Guidelines
HTC Corporation
01/19/2017 Ver. 1.3
29
HTC Confidential and Proprietary
The following is a Unity example code:
Figure: Unity example code for accessory integration (1)
public class Accessory : MonoBehaviour {
const float dX = 0.0100224f;
const float dY = -0.07616526f;
const float dZ = 0.4884118f;
const float roll = 10.854305f;
const float yaw = 91.8736f;
const float pitch = 78.805113f;
void Update () {
//Collect delta rotation and displacement between Tracker and Accessory
Vector3 delta_displacement = new Vector3(dX, dY, dZ);
Quaternion delta_rotation = Quaternion.Euler(roll, yaw, pitch);
//Get current Tracker pose
Vector3 tracker_position = SteamVR_Controller.Input(3).transform.pos;
Quaternion tracker_rotation = SteamVR_Controller.Input(3).transform.rot;
//Transform current Tracker pose to Accessory pose
GameObject.Find("Accessory ").transform.rotation = tracker_rotation * delta_rotation;
GameObject.Find("Accessory ").transform.position = tracker_po (tracker_rotation *
delta_rotation) * delta_displacement;
}
}