29 lines
897 B
C#
29 lines
897 B
C#
using UnityEngine;
|
|
|
|
namespace Models
|
|
{
|
|
public struct RotationNode
|
|
{
|
|
public HumanBodyBones UnityName;
|
|
public Quaternion PreviousRotation;
|
|
public Quaternion Rotation;
|
|
|
|
public Quaternion CalculateRotate => PreviousRotation * Quaternion.Inverse(PreviousRotation);
|
|
|
|
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;
|
|
|
|
var forward = new Vector3(end.X - begin.X, end.Y - begin.Y, end.Z - begin.Z);
|
|
Rotation = Quaternion.LookRotation(forward);
|
|
}
|
|
}
|
|
} |