123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Kinect = Windows.Kinect;
- // TODO: Implementing color feedback
- public class BodyComparer : MonoBehaviour
- {
- public BodySourceView bsv;
- private List<JointsData> jointsDataDemo = new List<JointsData>();
- private List<float> recordingTimesDemo = new List<float>();
- public void SetDataDemo(List<JointsData> jointsDataDemo, List<float> recordingTimesDemo)
- {
- this.jointsDataDemo = jointsDataDemo;
- this.recordingTimesDemo = recordingTimesDemo;
- }
- public IEnumerator StartCompare()
- {
- for (int i = 0; i < jointsDataDemo.Count; i++)
- {
- Transform body = bsv.body.transform;
- for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
- {
- // Skip these joints
- if (jt == Kinect.JointType.Head || jt == Kinect.JointType.ThumbLeft || jt == Kinect.JointType.ThumbRight
- || jt == Kinect.JointType.HandLeft || jt == Kinect.JointType.HandRight
- || jt == Kinect.JointType.HandTipLeft || jt == Kinect.JointType.HandTipRight)
- continue;
- JointsData jd = jointsDataDemo[i];
- Vector3 posJointDemo = new Vector3(jd.jointsPositionsX[(int)jt], jd.jointsPositionsY[(int)jt], jd.jointsPositionsZ[(int)jt]);
- //float distance = (joints[index].position - posJointDemo).magnitude;
- float distance = (body.GetChild((int)jt).position - posJointDemo).magnitude;
-
- if (distance > 0.15f)
- {
- //joints[index].GetComponent<Renderer>().material.color = Color.red;
- body.GetChild((int)jt).GetComponent<Renderer>().material.color = Color.red;
- }
- else
- {
- //joints[index].GetComponent<Renderer>().material.color = Color.white;
- body.GetChild((int)jt).GetComponent<Renderer>().material.color = Color.white;
- }
- }
- float waitTime = 0.01f;
- if (i < recordingTimesDemo.Count - 1)
- {
- waitTime = recordingTimesDemo[i + 1] - recordingTimesDemo[i];
- }
- yield return new WaitForSeconds(waitTime);
- }
- // TODO: make all of them white
- }
- }
|