EasyManua.ls Logo

HTC VIVE Tracker 3.0 - Page 30

HTC VIVE Tracker 3.0
45 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 (3.0)
HTC Corporation
Developer Guidelines
V1.0
12/16/2020
27 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 (3.0) (AxisY_Tracker, AxisZ_Tracker in the
example below) and the accessory (AxisY_Accessory, AxisZ_Accessory in the example
below).
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 3.0