using System.Collections; using System.Collections.Generic; using UnityEngine; namespace UDE_HAND_INTERACTION { [System.Serializable] public class HandJointsSet { public HandJointId id; public Transform transform; public Vector3 rotationOffset; public Quaternion RotationOffset { get { return Quaternion.Euler(rotationOffset); } } public Quaternion TrackedRotation { get { return Quaternion.Inverse(RotationOffset) * transform.localRotation; } } } [System.Serializable] public class JointCollection { /// /// List of indices of the joints in the actual rig for quick access /// [SerializeField] [HideInInspector] private int[] _jointIndices = new int[FingersData.HAND_JOINT_IDS.Length]; /// /// List of joints in the actual rig /// [SerializeField] [HideInInspector] private List _jointSets; public JointCollection(List joints) { _jointSets = joints; for (int i = 0; i < FingersData.HAND_JOINT_IDS.Length; i++) { HandJointId boneId = FingersData.HAND_JOINT_IDS[i]; _jointIndices[i] = joints.FindIndex(bone => bone.id == boneId); } } public HandJointsSet this[int jointIndex] { get { int joint = _jointIndices[jointIndex]; if (joint >= 0) { return _jointSets[joint]; } return null; } } } }