feature: 添加z轴压缩处理类 修复了身体前倾的问题
This commit is contained in:
parent
e63a32b95f
commit
b45aee859b
|
@ -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);
|
||||||
|
|
20
Assets/Utils/PoseTransformHandlers/ZAxisHandler.cs
Normal file
20
Assets/Utils/PoseTransformHandlers/ZAxisHandler.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Utils/PoseTransformHandlers/ZAxisHandler.cs.meta
Normal file
3
Assets/Utils/PoseTransformHandlers/ZAxisHandler.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 12369669a7fc44eaae881f89678649b1
|
||||||
|
timeCreated: 1678024599
|
Loading…
Reference in New Issue
Block a user