// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using System.Collections.Generic; using UltimateXR.Core; using UltimateXR.Core.Settings; using UnityEngine; using UnityEngine.XR; namespace UltimateXR.Devices.Integrations { /// /// Base class for tracking devices based on OpenVR. /// public abstract class UxrUnityXRControllerTracking : UxrControllerTracking { #region Protected Overrides UxrTrackingDevice /// protected override void UpdateSensors() { base.UpdateSensors(); if (Avatar.CameraComponent == null) { if (UxrGlobalSettings.Instance.LogLevelDevices >= UxrLogLevel.Warnings) { Debug.LogWarning($"{UxrConstants.DevicesModule}: No camera has been setup for this avatar"); } return; } List nodeStates = new List(); InputTracking.GetNodeStates(nodeStates); foreach (XRNodeState nodeState in nodeStates) { if (nodeState.nodeType == XRNode.LeftHand) { Vector3 localAvatarLeftHandSensorPos = LocalAvatarLeftHandSensorPos; Quaternion localAvatarLeftHandSensorRot = LocalAvatarLeftHandSensorRot; nodeState.TryGetRotation(out localAvatarLeftHandSensorRot); nodeState.TryGetPosition(out localAvatarLeftHandSensorPos); UpdateSensor(UxrHandSide.Left, localAvatarLeftHandSensorPos, localAvatarLeftHandSensorRot); } else if (nodeState.nodeType == XRNode.RightHand) { Vector3 localAvatarRightHandSensorPos = LocalAvatarRightHandSensorPos; Quaternion localAvatarRightHandSensorRot = LocalAvatarRightHandSensorRot; nodeState.TryGetRotation(out localAvatarRightHandSensorRot); nodeState.TryGetPosition(out localAvatarRightHandSensorPos); UpdateSensor(UxrHandSide.Right, localAvatarRightHandSensorPos, localAvatarRightHandSensorRot); } } } #endregion } }