2023-03-29 22:58:07 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace Models
|
|
|
|
{
|
|
|
|
public struct RotationNode
|
|
|
|
{
|
2023-03-30 14:26:38 +08:00
|
|
|
public readonly HumanBodyBones UnityName;
|
2023-03-29 22:58:07 +08:00
|
|
|
public Quaternion PreviousRotation;
|
|
|
|
public Quaternion Rotation;
|
|
|
|
|
2023-03-30 14:26:38 +08:00
|
|
|
public Quaternion CalculateRotate => PreviousRotation * Quaternion.Inverse(Rotation);
|
2023-03-29 22:58:07 +08:00
|
|
|
|
|
|
|
public RotationNode(HumanBodyBones humanBodyBone, Quaternion previousRotation, Quaternion rotation)
|
|
|
|
{
|
|
|
|
UnityName = humanBodyBone;
|
|
|
|
PreviousRotation = previousRotation;
|
|
|
|
Rotation = rotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public RotationNode(RotationNode node, PoseLandmark begin, PoseLandmark end)
|
|
|
|
{
|
|
|
|
UnityName = node.UnityName;
|
|
|
|
PreviousRotation = node.Rotation;
|
|
|
|
|
2023-03-30 14:26:38 +08:00
|
|
|
var forward = end.Position - begin.Position;
|
2023-03-29 22:58:07 +08:00
|
|
|
Rotation = Quaternion.LookRotation(forward);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|