2019-10-31 17:38:58 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Windows.Kinect;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace cylvester
|
|
|
|
|
{
|
|
|
|
|
public class Skeleton : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] private GameObject spherePrefab;
|
|
|
|
|
|
|
|
|
|
private GameObject[] balls_;
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
balls_ = new GameObject[25];
|
|
|
|
|
for (var i = 0; i < 25; ++i)
|
|
|
|
|
{
|
|
|
|
|
balls_[i] = Instantiate(spherePrefab, gameObject.transform, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-03 14:19:11 +00:00
|
|
|
|
public void OnSkeletonFrameReceived(Body body, int id)
|
2019-10-31 17:38:58 +00:00
|
|
|
|
{
|
2019-11-03 14:19:11 +00:00
|
|
|
|
var i = 0;
|
|
|
|
|
foreach(var pair in body.Joints)
|
2019-10-31 17:38:58 +00:00
|
|
|
|
{
|
2019-11-03 14:19:11 +00:00
|
|
|
|
var joint = pair.Value;
|
|
|
|
|
if(joint.TrackingState == TrackingState.NotTracked)
|
|
|
|
|
balls_[i].SetActive(false);
|
|
|
|
|
else
|
2019-10-31 17:38:58 +00:00
|
|
|
|
{
|
2019-11-03 14:19:11 +00:00
|
|
|
|
balls_[i].SetActive(true);
|
|
|
|
|
balls_[i].transform.position = new Vector3(joint.Position.X * 10f , joint.Position.Y * 10f, 0f);
|
2019-10-31 17:38:58 +00:00
|
|
|
|
}
|
2019-11-03 14:19:11 +00:00
|
|
|
|
i++;
|
2019-10-31 17:38:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|