Ejemplo n.º 1
0
 void Start()
 {
     //Debug.Log("LETS START");
     _BodyManager = FindObjectOfType <BodySceneManager>();
     pickBone     = gameObject.transform;
 }
Ejemplo n.º 2
0
 void Start()
 {
     _BodyManager = FindObjectOfType <BodySceneManager>();
     pickBone     = gameObject.transform;
 }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (BodySceneManager == null)
        {
            return;
        }

        _BodyManager = BodySceneManager.GetComponent <BodySceneManager>();
        if (_BodyManager == null)
        {
            return;
        }

        Kinect.Body[] data = _BodyManager.GetData();
        if (data == null)
        {
            return;
        }



        List <ulong> trackedIds = new List <ulong>();

        foreach (var body in data)
        {
            if (body == null)
            {
                continue;
            }

            if (body.IsTracked)
            {
                trackedIds.Add(body.TrackingId);
            }
        }

        List <ulong> knownIds = new List <ulong>(_Bodies.Keys);

        // First delete untracked bodies
        foreach (ulong trackingId in knownIds)
        {
            if (!trackedIds.Contains(trackingId))
            {
                Destroy(_Bodies[trackingId]);
                _Bodies.Remove(trackingId);
                //Debug.Log("untracked bodies delete!!");
            }
        }

        foreach (var body in data)
        {
            if (body == null)
            {
                continue;
            }

            if (body.IsTracked)
            {
                //처음 그리기
                if (!_Bodies.ContainsKey(body.TrackingId))
                {
                    _Bodies[body.TrackingId] = CreateBodyObject(body.TrackingId);
                }
                //새로 계속 그려주기
                //RefreshBodyObject(body, _Bodies[body.TrackingId]);

                trackingRoot(body);
            }
        }
    }