void Awake() { newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses); HmdMatrix44_t mat = new HmdMatrix44_t(); /**************************************/ /* * -0.102501 0.19387 0.975658 0.690977 * 0.00933648 0.980968 -0.193944 0.545085 * -0.994689 -0.0107702 -0.10236 -0.111363 * 0 0 0 1 */ /* * mat.m0 = -0.102501f; * mat.m1 = 0.19387f; * mat.m2 = 0.975658f; * mat.m3 = 0.690977f; * mat.m4 = 0.00933648f; * mat.m5 = 0.980968f; * mat.m6 = -0.193944f; * mat.m7 = 0.545085f; * mat.m8 = -0.994689f; * mat.m9 = -0.0107702f; * mat.m10 = -0.10236f; * mat.m11 = -0.111363f; * mat.m12 = 0; * mat.m13 = 0; * mat.m14 = 0; * mat.m15 = 1; */ mat.m0 = -0.102501f; mat.m4 = 0.19387f; mat.m8 = 0.975658f; mat.m12 = 0.690977f; mat.m1 = 0.00933648f; mat.m5 = 0.980968f; mat.m9 = -0.193944f; mat.m13 = 0.545085f; mat.m2 = -0.994689f; mat.m6 = -0.0107702f; mat.m10 = -0.10236f; mat.m14 = -0.111363f; mat.m3 = 0; mat.m7 = 0; mat.m11 = 0; mat.m15 = 1; /**************************************/ BMatInv = new SteamVR_Utils.RigidTransform(mat); BMatInv.Inverse(); }
public SteamVR_Utils.RigidTransform GetInverse() { SteamVR_Utils.RigidTransform result = new SteamVR_Utils.RigidTransform(this.pos, this.rot); result.Inverse(); return(result); }
private void OnNewPoses(params object[] args) { if (_type != Type) { _type = Type; IsValid = false; } if (!IsValid) { Index = EIndex.None; if (Type != EType.None) { switch (Type) { case EType.HMD: if (HOTK_TrackedDeviceManager.Instance.HMDIndex != OpenVR.k_unTrackedDeviceIndexInvalid) { Index = (EIndex)HOTK_TrackedDeviceManager.Instance.HMDIndex; } break; case EType.LeftController: if (HOTK_TrackedDeviceManager.Instance.LeftIndex != OpenVR.k_unTrackedDeviceIndexInvalid) { Index = (EIndex)HOTK_TrackedDeviceManager.Instance.LeftIndex; } break; case EType.RightController: if (HOTK_TrackedDeviceManager.Instance.RightIndex != OpenVR.k_unTrackedDeviceIndexInvalid) { Index = (EIndex)HOTK_TrackedDeviceManager.Instance.RightIndex; } break; default: throw new ArgumentOutOfRangeException(); } } } IsValid = false; if (Index == EIndex.None) { return; } var i = (int)Index; var poses = (TrackedDevicePose_t[])args[0]; if (poses.Length <= i) { return; } if (!poses[i].bDeviceIsConnected) { return; } if (!poses[i].bPoseIsValid) { return; } IsValid = true; var pose = new SteamVR_Utils.RigidTransform(poses[i].mDeviceToAbsoluteTracking); if (OpenVR.Compositor.GetTrackingSpace() != ETrackingUniverseOrigin.TrackingUniverseSeated) { var transform = new SteamVR_Utils.RigidTransform(OpenVR.System.GetSeatedZeroPoseToStandingAbsoluteTrackingPose()); transform.Inverse(); pose = transform * pose; } if (Origin != null) { pose = new SteamVR_Utils.RigidTransform(Origin) * pose; pose.pos.x *= Origin.localScale.x; pose.pos.y *= Origin.localScale.y; pose.pos.z *= Origin.localScale.z; transform.position = pose.pos; transform.rotation = pose.rot; } else { transform.localPosition = pose.pos; transform.localRotation = pose.rot; } }