EasyManua.ls Logo

HTC Vive Tracker - Page 35

HTC Vive Tracker
47 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Vive Tracker
Developer Guidelines
HTC Corporation 07/17/2017
V
er.
1.5
32
HTC Confidential and Proprietary
Another Unity sample code shows how to transform the accessory by comparing vectors
parallel to y-axis and z-axis of the Vive Tracker (AxisY_Tracker, AxisZ_Tracker in example
below) and the accessory (AxisY_Accessory, AxisZ_Accessory in example below).
Figure: Unity sample code for accessory integration (2)
public class Accessory : MonoBehaviour {
const Vector3 AxisY_Tracker = new Vectors(AxisY_Tracker_X, AxisY_Tracker_Y,
AxisY_Tracker_Z);
const Vector3 AxisZ_Tracker = new Vectors(AxisZ_Tracker_X, AxisZ_Tracker_Y,
AxisZ_Tracker_Z);
const Vector3 AxisY_Accessory = new Vectors(AxisY_ Accessory _X, AxisY_ Accessory _Y,
AxisY_ Accessory _Z);
const Vector3 AxisZ_ Accessory = new Vectors(AxisZ_ Accessory _X, AxisZ_ Accessory _Y,
AxisZ_ Accessory _Z);
void Update () {
//Calculate delta rotation by comparing vectors parallel to Y axes of Tracker and the accessory
Quaternion delta_rotY = Quaternion.FromToRotation(AxisY_Tracker, AxisY_Accessory);
AxisZ_Tracker = delta_rotY * AxisZ_Tracker;
Quaternion delta_rotZ = Quaternion.FromToRotation(AxisZ_Tracker, AxisZ_Accessory);
//Collect delta rotation and displacement between Tracker and Accessory
Vector3 delta_displacement = new Vector3(dX, dY, dZ);
Quaternion delta_rotation = delta_rotZ * delta_rotY;
//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 = delta_rotation * tracker_rotation;
GameObject.Find("Accessory ").transform.position = tracker_position + (delta_rotation *
tracker_rotation) * delta_displacement;
}
}

Other manuals for HTC Vive Tracker

Related product manuals