fix: 人物坐标旋转为正对
This commit is contained in:
		| @@ -1,8 +1,6 @@ | |||||||
| using System; | using System; | ||||||
| using System.Collections; |  | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using Models; | using Models; | ||||||
| using Unity.VisualScripting; |  | ||||||
| using UnityEngine; | using UnityEngine; | ||||||
| 
 | 
 | ||||||
| public class MainBehaviour : MonoBehaviour | public class MainBehaviour : MonoBehaviour | ||||||
| @@ -10,6 +8,7 @@ public class MainBehaviour : MonoBehaviour | |||||||
|     private readonly List<GameObject> _nodes = new List<GameObject>(); |     private readonly List<GameObject> _nodes = new List<GameObject>(); | ||||||
|     private readonly List<PoseTransform> _poseTransforms = new List<PoseTransform>(); |     private readonly List<PoseTransform> _poseTransforms = new List<PoseTransform>(); | ||||||
|     private readonly UdpListener _listener = new UdpListener(); |     private readonly UdpListener _listener = new UdpListener(); | ||||||
|  |     private const float _scale = 0.2f; | ||||||
|      |      | ||||||
| 
 | 
 | ||||||
|     // Start is called before the first frame update |     // Start is called before the first frame update | ||||||
| @@ -31,10 +30,10 @@ public class MainBehaviour : MonoBehaviour | |||||||
|             var temp = new Vector4(_poseTransforms[index].MediaPipePos.x, |             var temp = new Vector4(_poseTransforms[index].MediaPipePos.x, | ||||||
|                                    _poseTransforms[index].MediaPipePos.y, |                                    _poseTransforms[index].MediaPipePos.y, | ||||||
|                                     _poseTransforms[index].MediaPipePos.z,1); |                                     _poseTransforms[index].MediaPipePos.z,1); | ||||||
|             //temp = RotateAxisZ(180) * temp; |             temp = RotateAxisX(-45) * temp; | ||||||
|             //warning:乘法的顺序不能改! |             //warning:乘法的顺序不能改! | ||||||
|              |              | ||||||
|             _nodes[index].transform.position = new Vector3(temp.x, temp.y, temp.z) * 5; |             _nodes[index].transform.position = new Vector3(-temp.x, -temp.y, -temp.z) * 5; | ||||||
|             //_nodes[index].transform.position = _poseTransforms[index].MediaPipePos * 5; |             //_nodes[index].transform.position = _poseTransforms[index].MediaPipePos * 5; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -50,17 +49,17 @@ public class MainBehaviour : MonoBehaviour | |||||||
|         { |         { | ||||||
|             var ball = GameObject.CreatePrimitive(PrimitiveType.Sphere); |             var ball = GameObject.CreatePrimitive(PrimitiveType.Sphere); | ||||||
| 
 | 
 | ||||||
|             ball.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); |             ball.transform.localScale = new Vector3(_scale, _scale, _scale); | ||||||
| 
 | 
 | ||||||
|             if (i <= 10) |             if (i <= 10) | ||||||
|             { |             { | ||||||
|                 ball.GetComponent<Renderer>().material.color = Color.red;//给头部添加颜色 |                 ball.GetComponent<Renderer>().material.color = Color.red;//给头部添加颜色 | ||||||
|             } |             } | ||||||
|             else if (i > 10 && i <= 22) |             else if (i <= 22) | ||||||
|             { |             { | ||||||
|                 ball.GetComponent<Renderer>().material.color = Color.blue;//给手部添加颜色 |                 ball.GetComponent<Renderer>().material.color = Color.blue;//给手部添加颜色 | ||||||
|             } |             } | ||||||
|             else if (i > 12 && i <= 32) |             else if (i <= 32) | ||||||
|             { |             { | ||||||
|                 ball.GetComponent<Renderer>().material.color = Color.green;//给脚部添加颜色 |                 ball.GetComponent<Renderer>().material.color = Color.green;//给脚部添加颜色 | ||||||
|             } |             } | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								Assets/Materials.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assets/Materials.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | |||||||
|  | fileFormatVersion: 2 | ||||||
|  | guid: c2963c03969c7f6d480483b45e36590b | ||||||
|  | folderAsset: yes | ||||||
|  | DefaultImporter: | ||||||
|  |   externalObjects: {} | ||||||
|  |   userData:  | ||||||
|  |   assetBundleName:  | ||||||
|  |   assetBundleVariant:  | ||||||
							
								
								
									
										80
									
								
								Assets/Materials/PlaneMaterial.mat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								Assets/Materials/PlaneMaterial.mat
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,80 @@ | |||||||
|  | %YAML 1.1 | ||||||
|  | %TAG !u! tag:unity3d.com,2011: | ||||||
|  | --- !u!21 &2100000 | ||||||
|  | Material: | ||||||
|  |   serializedVersion: 8 | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   m_Name: PlaneMaterial | ||||||
|  |   m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} | ||||||
|  |   m_ValidKeywords: [] | ||||||
|  |   m_InvalidKeywords: [] | ||||||
|  |   m_LightmapFlags: 4 | ||||||
|  |   m_EnableInstancingVariants: 0 | ||||||
|  |   m_DoubleSidedGI: 0 | ||||||
|  |   m_CustomRenderQueue: -1 | ||||||
|  |   stringTagMap: {} | ||||||
|  |   disabledShaderPasses: [] | ||||||
|  |   m_SavedProperties: | ||||||
|  |     serializedVersion: 3 | ||||||
|  |     m_TexEnvs: | ||||||
|  |     - _BumpMap: | ||||||
|  |         m_Texture: {fileID: 0} | ||||||
|  |         m_Scale: {x: 1, y: 1} | ||||||
|  |         m_Offset: {x: 0, y: 0} | ||||||
|  |     - _DetailAlbedoMap: | ||||||
|  |         m_Texture: {fileID: 0} | ||||||
|  |         m_Scale: {x: 1, y: 1} | ||||||
|  |         m_Offset: {x: 0, y: 0} | ||||||
|  |     - _DetailMask: | ||||||
|  |         m_Texture: {fileID: 0} | ||||||
|  |         m_Scale: {x: 1, y: 1} | ||||||
|  |         m_Offset: {x: 0, y: 0} | ||||||
|  |     - _DetailNormalMap: | ||||||
|  |         m_Texture: {fileID: 0} | ||||||
|  |         m_Scale: {x: 1, y: 1} | ||||||
|  |         m_Offset: {x: 0, y: 0} | ||||||
|  |     - _EmissionMap: | ||||||
|  |         m_Texture: {fileID: 0} | ||||||
|  |         m_Scale: {x: 1, y: 1} | ||||||
|  |         m_Offset: {x: 0, y: 0} | ||||||
|  |     - _MainTex: | ||||||
|  |         m_Texture: {fileID: 0} | ||||||
|  |         m_Scale: {x: 1, y: 1} | ||||||
|  |         m_Offset: {x: 0, y: 0} | ||||||
|  |     - _MetallicGlossMap: | ||||||
|  |         m_Texture: {fileID: 0} | ||||||
|  |         m_Scale: {x: 1, y: 1} | ||||||
|  |         m_Offset: {x: 0, y: 0} | ||||||
|  |     - _OcclusionMap: | ||||||
|  |         m_Texture: {fileID: 0} | ||||||
|  |         m_Scale: {x: 1, y: 1} | ||||||
|  |         m_Offset: {x: 0, y: 0} | ||||||
|  |     - _ParallaxMap: | ||||||
|  |         m_Texture: {fileID: 0} | ||||||
|  |         m_Scale: {x: 1, y: 1} | ||||||
|  |         m_Offset: {x: 0, y: 0} | ||||||
|  |     m_Ints: [] | ||||||
|  |     m_Floats: | ||||||
|  |     - _BumpScale: 1 | ||||||
|  |     - _Cutoff: 0.5 | ||||||
|  |     - _DetailNormalMapScale: 1 | ||||||
|  |     - _DstBlend: 0 | ||||||
|  |     - _GlossMapScale: 1 | ||||||
|  |     - _Glossiness: 0.5 | ||||||
|  |     - _GlossyReflections: 1 | ||||||
|  |     - _Metallic: 0 | ||||||
|  |     - _Mode: 0 | ||||||
|  |     - _OcclusionStrength: 1 | ||||||
|  |     - _Parallax: 0.02 | ||||||
|  |     - _SmoothnessTextureChannel: 0 | ||||||
|  |     - _SpecularHighlights: 1 | ||||||
|  |     - _SrcBlend: 1 | ||||||
|  |     - _UVSec: 0 | ||||||
|  |     - _ZWrite: 1 | ||||||
|  |     m_Colors: | ||||||
|  |     - _Color: {r: 1, g: 0.29922488, b: 0, a: 1} | ||||||
|  |     - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} | ||||||
|  |   m_BuildTextureStacks: [] | ||||||
							
								
								
									
										8
									
								
								Assets/Materials/PlaneMaterial.mat.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assets/Materials/PlaneMaterial.mat.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | |||||||
|  | fileFormatVersion: 2 | ||||||
|  | guid: 6083fe04391087ca294999838984a59c | ||||||
|  | NativeFormatImporter: | ||||||
|  |   externalObjects: {} | ||||||
|  |   mainObjectFileID: 2100000 | ||||||
|  |   userData:  | ||||||
|  |   assetBundleName:  | ||||||
|  |   assetBundleVariant:  | ||||||
| @@ -123,6 +123,104 @@ NavMeshSettings: | |||||||
|     debug: |     debug: | ||||||
|       m_Flags: 0 |       m_Flags: 0 | ||||||
|   m_NavMeshData: {fileID: 0} |   m_NavMeshData: {fileID: 0} | ||||||
|  | --- !u!1 &99618223 | ||||||
|  | GameObject: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   serializedVersion: 6 | ||||||
|  |   m_Component: | ||||||
|  |   - component: {fileID: 99618227} | ||||||
|  |   - component: {fileID: 99618226} | ||||||
|  |   - component: {fileID: 99618225} | ||||||
|  |   - component: {fileID: 99618224} | ||||||
|  |   m_Layer: 0 | ||||||
|  |   m_Name: Plane | ||||||
|  |   m_TagString: Untagged | ||||||
|  |   m_Icon: {fileID: 0} | ||||||
|  |   m_NavMeshLayer: 0 | ||||||
|  |   m_StaticEditorFlags: 0 | ||||||
|  |   m_IsActive: 1 | ||||||
|  | --- !u!64 &99618224 | ||||||
|  | MeshCollider: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   m_GameObject: {fileID: 99618223} | ||||||
|  |   m_Material: {fileID: 0} | ||||||
|  |   m_IsTrigger: 0 | ||||||
|  |   m_Enabled: 1 | ||||||
|  |   serializedVersion: 4 | ||||||
|  |   m_Convex: 0 | ||||||
|  |   m_CookingOptions: 30 | ||||||
|  |   m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} | ||||||
|  | --- !u!23 &99618225 | ||||||
|  | MeshRenderer: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   m_GameObject: {fileID: 99618223} | ||||||
|  |   m_Enabled: 1 | ||||||
|  |   m_CastShadows: 1 | ||||||
|  |   m_ReceiveShadows: 1 | ||||||
|  |   m_DynamicOccludee: 1 | ||||||
|  |   m_StaticShadowCaster: 0 | ||||||
|  |   m_MotionVectors: 1 | ||||||
|  |   m_LightProbeUsage: 1 | ||||||
|  |   m_ReflectionProbeUsage: 1 | ||||||
|  |   m_RayTracingMode: 2 | ||||||
|  |   m_RayTraceProcedural: 0 | ||||||
|  |   m_RenderingLayerMask: 1 | ||||||
|  |   m_RendererPriority: 0 | ||||||
|  |   m_Materials: | ||||||
|  |   - {fileID: 2100000, guid: 6083fe04391087ca294999838984a59c, type: 2} | ||||||
|  |   m_StaticBatchInfo: | ||||||
|  |     firstSubMesh: 0 | ||||||
|  |     subMeshCount: 0 | ||||||
|  |   m_StaticBatchRoot: {fileID: 0} | ||||||
|  |   m_ProbeAnchor: {fileID: 0} | ||||||
|  |   m_LightProbeVolumeOverride: {fileID: 0} | ||||||
|  |   m_ScaleInLightmap: 1 | ||||||
|  |   m_ReceiveGI: 1 | ||||||
|  |   m_PreserveUVs: 0 | ||||||
|  |   m_IgnoreNormalsForChartDetection: 0 | ||||||
|  |   m_ImportantGI: 0 | ||||||
|  |   m_StitchLightmapSeams: 1 | ||||||
|  |   m_SelectedEditorRenderState: 3 | ||||||
|  |   m_MinimumChartSize: 4 | ||||||
|  |   m_AutoUVMaxDistance: 0.5 | ||||||
|  |   m_AutoUVMaxAngle: 89 | ||||||
|  |   m_LightmapParameters: {fileID: 0} | ||||||
|  |   m_SortingLayerID: 0 | ||||||
|  |   m_SortingLayer: 0 | ||||||
|  |   m_SortingOrder: 0 | ||||||
|  |   m_AdditionalVertexStreams: {fileID: 0} | ||||||
|  | --- !u!33 &99618226 | ||||||
|  | MeshFilter: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   m_GameObject: {fileID: 99618223} | ||||||
|  |   m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} | ||||||
|  | --- !u!4 &99618227 | ||||||
|  | Transform: | ||||||
|  |   m_ObjectHideFlags: 0 | ||||||
|  |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  |   m_PrefabInstance: {fileID: 0} | ||||||
|  |   m_PrefabAsset: {fileID: 0} | ||||||
|  |   m_GameObject: {fileID: 99618223} | ||||||
|  |   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||||||
|  |   m_LocalPosition: {x: 0, y: 0, z: 0} | ||||||
|  |   m_LocalScale: {x: 1, y: 1, z: 1} | ||||||
|  |   m_ConstrainProportionsScale: 1 | ||||||
|  |   m_Children: [] | ||||||
|  |   m_Father: {fileID: 0} | ||||||
|  |   m_RootOrder: 3 | ||||||
|  |   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||||||
| --- !u!1 &182244630 | --- !u!1 &182244630 | ||||||
| GameObject: | GameObject: | ||||||
|   m_ObjectHideFlags: 0 |   m_ObjectHideFlags: 0 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user