From 2a0047a04b5a213c4005f04793bf479f56a0fd12 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Thu, 30 Mar 2023 21:18:20 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Behaviours/BoneBehaviour.cs | 29 ++++++++++++++++++++++------- Assets/Models/Bond.cs | 2 ++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Assets/Behaviours/BoneBehaviour.cs b/Assets/Behaviours/BoneBehaviour.cs index a96832f..a187bd0 100644 --- a/Assets/Behaviours/BoneBehaviour.cs +++ b/Assets/Behaviours/BoneBehaviour.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using Models; using UnityEngine; @@ -31,7 +32,8 @@ private void Update() { if (_isReceived) { - _animator.GetBoneTransform(HumanBodyBones.Hips).rotation = _rotationNodes[HumanBodyBones.Hips].Rotation; + _animator.GetBoneTransform(HumanBodyBones.Hips).rotation = + _rotationNodes[HumanBodyBones.Hips].Rotation; /*var rotation = _rotationNodes[HumanBodyBones.Hips].CalculateRotate * Quaternion.Inverse(_rotationNodes[HumanBodyBones.RightUpperArm].CalculateRotate); @@ -52,16 +54,34 @@ private void Update() } _animator.GetBoneTransform(HumanBodyBones.LeftUpperArm).rotation = _bonds[9].Rotation; + _animator.GetBoneTransform(HumanBodyBones.LeftUpperArm).Rotate(0, -180, 0, + Space.Self); _animator.GetBoneTransform(HumanBodyBones.LeftLowerArm).rotation = _bonds[10].Rotation; - + _animator.GetBoneTransform(HumanBodyBones.LeftLowerArm).Rotate(0, -180, 0, + Space.Self); + _animator.GetBoneTransform(HumanBodyBones.RightUpperArm).rotation = _bonds[15].Rotation; + _animator.GetBoneTransform(HumanBodyBones.RightUpperArm).Rotate(0, -180, 0, + Space.Self); + _animator.GetBoneTransform(HumanBodyBones.RightLowerArm).rotation = _bonds[16].Rotation; + _animator.GetBoneTransform(HumanBodyBones.RightLowerArm).Rotate(0, -180, 0, + Space.Self); _animator.GetBoneTransform(HumanBodyBones.LeftUpperLeg).rotation = _bonds[22].Rotation; + _animator.GetBoneTransform(HumanBodyBones.LeftUpperLeg).Rotate(0, -180, 0, + Space.Self); _animator.GetBoneTransform(HumanBodyBones.LeftLowerLeg).rotation = _bonds[23].Rotation; + _animator.GetBoneTransform(HumanBodyBones.LeftLowerLeg).Rotate(0, -180, 0, + Space.Self); _animator.GetBoneTransform(HumanBodyBones.RightUpperLeg).rotation = _bonds[28].Rotation; + _animator.GetBoneTransform(HumanBodyBones.RightUpperLeg).Rotate(0, -180, 0, + Space.Self); + _animator.GetBoneTransform(HumanBodyBones.RightLowerLeg).rotation = _bonds[29].Rotation; + _animator.GetBoneTransform(HumanBodyBones.RightLowerLeg).Rotate(0, -180, 0, + Space.Self); _isReceived = false; } @@ -94,11 +114,6 @@ private void OnReceive(List landmarks) oldRotation.Rotation, Quaternion.LookRotation(front)); - _rotationNodes[HumanBodyBones.RightUpperArm] = new RotationNode( - _rotationNodes[HumanBodyBones.RightUpperArm], - landmarks[PoseLandmarkType.RightShoulder], - landmarks[PoseLandmarkType.RightElbow]); - _landmarks = landmarks; _isReceived = true; } diff --git a/Assets/Models/Bond.cs b/Assets/Models/Bond.cs index d77f33b..3044302 100644 --- a/Assets/Models/Bond.cs +++ b/Assets/Models/Bond.cs @@ -1,4 +1,5 @@ using UnityEngine; +using Utils; namespace Models { @@ -12,6 +13,7 @@ public class Bond private readonly GameObject _bond; public Quaternion Rotation => _bond.transform.rotation; + public Vector3 Vector => End.transform.position - Start.transform.position; public Bond(GameObject start,GameObject end,float scale) {