12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- 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[] joints = bsv.body.GetComponentsInChildren<Transform>();
- int index = 0;
- 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;
- if (distance > 0.2f)
- {
- joints[index].GetComponent<Renderer>().material.color = Color.red;
- }
- else
- {
- joints[index].GetComponent<Renderer>().material.color = Color.white;
- }
- index++;
- }
- float waitTime = 1;
- if (i < recordingTimesDemo.Count - 1)
- {
- waitTime = recordingTimesDemo[i + 1] - recordingTimesDemo[i];
- }
- yield return new WaitForSeconds(waitTime);
- }
- }
- // TODO: maybe at the end need to make all of them white?
- }
|