fix: 修复版本问题,移除错误的文件

This commit is contained in:
Ichirinko
2023-02-19 21:09:46 +08:00
parent be507d250e
commit e6a19beb0c
6 changed files with 25 additions and 267 deletions

View File

@@ -1,179 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Models;
using UnityEngine;
public class ModelControler : MonoBehaviour
{
Animator animator;
//float deltaz = 0f;
//Vector3 upperArm = new Vector3(0f, 0f, 0f);
private Quaternion[] prevQ = new Quaternion[15];
private static Quaternion[] uniRotation = new Quaternion[15]; //全局两坐标系通用四元数
private readonly UdpListener _listener = new UdpListener();
private static Dictionary<string,(HumanBodyBones,int)> Landmarks_Mapping= new Dictionary<string,HumanBodyBones>();
void Start()
{
_listener.AddHandler(LogLandmarks);
_listener.AddHandler(RigPoint);
_listener.Connect(5000);
DictProcess(); //匹配字典初始化
// 获取动画控件
animator = this.GetComponent<Animator>();
GetOriginStatus(); // 获取骨骼的原始旋转角
}
// Update is called once per frame
void Update()
{
//deltaz += 1f;
//upperArm.z = deltaz;
//animator.GetBoneTransform(HumanBodyBones.RightLowerArm).rotation = uniRotation * prevQ ;
int pos=0;
foreach(var landmark in Landmarks_Mapping.Values)
{
animator.GetBoneTransform(landmark).rotation = uniRotation[pos];
pos++;
}
//animator.GetBoneTransform(HumanBodyBones.RightLowerArm).rotation = uniRotation[14];
}
private void OnDisable()
{
_listener.DisConnect();
}
private static void LogLandmarks(List<PoseLandmark> landmarks)
{
foreach (var landmark in landmarks)
{
Debug.Log(landmark.ToString());
}
}
//获取传上来的数据点坐标转换成四元数的回调函数
private static void RigPoint(List<PoseLandmark> landmarks)
{
int pos = 0;
foreach (var landmark in landmarks)
{
if(Landmarks_Mapping.ContainsKey(landmark.Type.ToString()))
{
Vector3 realPosition = new Vector3(landmark.X,landmark.Y,landmark.Z);
if(landmark.Visibility<0.8){
//uniRotation=(0f,0f);
}
else
{
uniRotation[pos] = Quaternion.LookRotation(realPosition);
pos++;
}
}
}
/*
Vector3 realPosition = new Vector3(landmarks[14].X,landmarks[14].Y,landmarks[14].Z);
if(landmarks[14].Visibility<0.8){
//uniRotation=(0f,0f);
}
else{
uniRotation[14] = Quaternion.LookRotation(realPosition);
}
//Debug.Log(uniRotation);
*/
}
private void DictProcess()
{
/*下面的语句的顺序最好别调换,不然可能会发生难以预料的事情*/
Landmarks_Mapping.Add("Nose",HumanBodyBones.Head); //0 10
Landmarks_Mapping.Add("LeftShoulder",HumanBodyBones.LeftUpperArm); //11
Landmarks_Mapping.Add("RightShoulder",HumanBodyBones.RightUpperArm); //12
Landmarks_Mapping.Add("LeftElbow",HumanBodyBones.LeftLowerArm); //13
Landmarks_Mapping.Add("RightElbow",HumanBodyBones.RightLowerArm); //14
Landmarks_Mapping.Add("LeftWrist",HumanBodyBones.LeftHand); //15
Landmarks_Mapping.Add("RightWrist",HumanBodyBones.RightHand); //16
Landmarks_Mapping.Add("LeftHip",HumanBodyBones.LeftUpperLeg); //23
Landmarks_Mapping.Add("RightHip",HumanBodyBones.RightUpperLeg); //24
Landmarks_Mapping.Add("LeftKnee",HumanBodyBones.LeftLowerLeg); //25
Landmarks_Mapping.Add("RightKnee",HumanBodyBones.RightLowerLeg); //26
Landmarks_Mapping.Add("LeftAnkle",HumanBodyBones.LeftFoot); //27
Landmarks_Mapping.Add("RightAnkle",HumanBodyBones.RightFoot); //28
Landmarks_Mapping.Add("LeftFootIndex",HumanBodyBones.LeftToes); //31
Landmarks_Mapping.Add("RightFootIndex",HumanBodyBones.RightToes); //32
}
private void GetOriginStatus()
{
int pos=0;
foreach(var landmarks in Landmarks_Mapping.Values)
{
prevQ[pos] = animator.GetBoneTransform(landmarks).rotation;
//Quaternion currentQ = Quaternion.Euler(upperArm.x, upperArm.y, upperArm.z);
//animator.GetBoneTransform(HumanBodyBones.LeftUpperArm).rotation = currentQ * prevQ;
uniRotation[pos] = prevQ[pos];
pos++;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: f3dc31402d1b12d4faa2846675feff35
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -234,11 +234,7 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
<<<<<<< Updated upstream
--- !u!1001 &421937415
=======
--- !u!1001 &404755305
>>>>>>> Stashed changes
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
@@ -259,11 +255,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c5470c9a1aff50643b6a9ff0bab4297d, type: 3}
propertyPath: m_LocalPosition.z
<<<<<<< Updated upstream
value: 5
=======
value: 0
>>>>>>> Stashed changes
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: c5470c9a1aff50643b6a9ff0bab4297d, type: 3}
propertyPath: m_LocalRotation.w
@@ -293,59 +285,29 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
<<<<<<< Updated upstream
- target: {fileID: -2845779275431937956, guid: c5470c9a1aff50643b6a9ff0bab4297d, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
=======
>>>>>>> Stashed changes
- target: {fileID: 919132149155446097, guid: c5470c9a1aff50643b6a9ff0bab4297d, type: 3}
propertyPath: m_Name
value: troop
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c5470c9a1aff50643b6a9ff0bab4297d, type: 3}
<<<<<<< Updated upstream
--- !u!1 &437000000 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: c5470c9a1aff50643b6a9ff0bab4297d, type: 3}
m_PrefabInstance: {fileID: 421937415}
m_PrefabAsset: {fileID: 0}
--- !u!114 &437000001
=======
--- !u!1 &404755306 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: c5470c9a1aff50643b6a9ff0bab4297d, type: 3}
m_PrefabInstance: {fileID: 404755305}
m_PrefabAsset: {fileID: 0}
--- !u!114 &404755307
>>>>>>> Stashed changes
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
<<<<<<< Updated upstream
m_GameObject: {fileID: 437000000}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f3dc31402d1b12d4faa2846675feff35, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &437000003 stripped
Transform:
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: c5470c9a1aff50643b6a9ff0bab4297d, type: 3}
m_PrefabInstance: {fileID: 421937415}
m_PrefabAsset: {fileID: 0}
=======
m_GameObject: {fileID: 404755306}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a2b30b6aa6e08c4468a02e1fcabcd485, type: 3}
m_Name:
m_EditorClassIdentifier:
>>>>>>> Stashed changes
--- !u!1 &705507993
GameObject:
m_ObjectHideFlags: 0
@@ -518,11 +480,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
<<<<<<< Updated upstream
m_LocalPosition: {x: 0, y: 9.29, z: 20}
=======
m_LocalPosition: {x: 0, y: 7, z: 15}
>>>>>>> Stashed changes
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []