Unity Udexreal开发插件包
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.8 KiB

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
{
/// <summary>
/// List of indices of the joints in the actual rig for quick access
/// </summary>
[SerializeField]
[HideInInspector]
private int[] _jointIndices = new int[FingersData.HAND_JOINT_IDS.Length];
/// <summary>
/// List of joints in the actual rig
/// </summary>
[SerializeField]
[HideInInspector]
private List<HandJointsSet> _jointSets;
public JointCollection(List<HandJointsSet> 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;
}
}
}
}