VIVE Tracker (3.0)
HTC Corporation
Developer Guidelines
V1.0
12/16/2020
26
HTC Confidential and Proprietary
The following is a Unity sample code (reference):
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;
}
}