MotionCapture/Assets/Models/RotationNode.cs

29 lines
865 B
C#
Raw Permalink Normal View History

using UnityEngine;
namespace Models
{
public struct RotationNode
{
2023-03-30 14:26:38 +08:00
public readonly HumanBodyBones UnityName;
public Quaternion PreviousRotation;
public Quaternion Rotation;
2023-03-30 14:26:38 +08:00
public Quaternion CalculateRotate => PreviousRotation * Quaternion.Inverse(Rotation);
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;
Rotation = Quaternion.LookRotation(forward);
}
}
}