feature: 添加z轴压缩处理类 修复了身体前倾的问题

This commit is contained in:
jackfiled 2023-03-05 22:26:01 +08:00
parent e63a32b95f
commit b45aee859b
3 changed files with 25 additions and 2 deletions

View File

@ -8,7 +8,7 @@ namespace Behaviours
public class BoneBehaviour : MonoBehaviour public class BoneBehaviour : MonoBehaviour
{ {
private readonly UdpListener _listener = new UdpListener(); private readonly UdpListener _listener = new UdpListener();
private PoseTransform[] _transforms = new PoseTransform[PoseLandmarkType.MaxValue]; private readonly PoseTransform[] _transforms = new PoseTransform[PoseLandmarkType.MaxValue];
private Animator _animator; private Animator _animator;
@ -18,7 +18,7 @@ private void Start()
for (var i = 0; i < PoseLandmarkType.MaxValue; i++) for (var i = 0; i < PoseLandmarkType.MaxValue; i++)
{ {
_transforms[i] = new PoseTransform(i, new NormalHandler()); _transforms[i] = new PoseTransform(i, new ZAxisHandler());
} }
_listener.AddHandler(OnReceive); _listener.AddHandler(OnReceive);

View File

@ -0,0 +1,20 @@
using Models;
using UnityEngine;
namespace Utils.PoseTransformHandlers
{
public class ZAxisHandler : IPoseTransformHandler
{
private Vector3 _result;
public void ReceivePoseLandmark(PoseLandmark landmark)
{
_result = new Vector3(landmark.X, landmark.Y, landmark.Z * 0.5f);
}
public Vector3 GetResultPosition()
{
return _result;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 12369669a7fc44eaae881f89678649b1
timeCreated: 1678024599