123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using UnityEngine;
- using System.Collections;
- using Windows.Kinect;
- public class JointPosition : MonoBehaviour
- {
- public Transform kinectPosition;
- public Windows.Kinect.JointType _jointType;
- public GameObject _bodySourceManager;
- private BodySourceManager _bodyManager;
- // Use this for initialization
- void Start ()
- {
-
- }
-
- // Update is called once per frame
- void Update ()
- {
- if (_bodySourceManager == null)
- {
- return;
- }
- _bodyManager = _bodySourceManager.GetComponent<BodySourceManager>();
- if (_bodyManager == null)
- {
- return;
- }
- Body[] data = _bodyManager.GetData();
- if (data == null)
- {
- return;
- }
- // get the first tracked body...
- foreach (Body body in data)
- {
- if (body == null)
- {
- continue;
- }
- if (body.IsTracked)
- {
- //this.gameObject.transform.position = new Vector3
- // this.gameObject.transform.localPosition = body.Joints[_jointType].Position;
- var pos = body.Joints[_jointType].Position;
- Vector3 tempVector = new Vector3(-pos.X , pos.Y , pos.Z );
- transform.position = tempVector;
- // transform.position = kinectPosition.TransformPoint (tempVector);
- break;
- }
- }
- }
- }
|