Beispiel #1
0
    void Update()
    {
        if (FaceMultiSourceManager == null)
        {
            return;
        }

        _MultiManager = FaceMultiSourceManager.GetComponent <FaceMultiSourceManager>();
        if (_MultiManager == null)
        {
            return;
        }

        if (_Monitor == null)
        {
            return;
        }

        _MonitorState = _Monitor.GetComponent <MonitorState>();
        if (_MonitorState == null)
        {
            return;
        }

        // EXPERIMANTAL depth data imlementation

//		ushort[] depthData = _MultiManager.GetDepthData();
//		if (depthData == null)
//		{
//			return;
//		}

        //

        //begin body
        Kinect.Body[] BodydataArray = _MultiManager.GetBodyData();
        if (BodydataArray == null)
        {
            return;
        }

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

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

            if (body.IsTracked)
            {
                trackedIds.Add(body.TrackingId);                 // msaw edit the next lines
                //if (TrackedBody == 0){
                //	TrackedBody = body.TrackingId;
                //Debug.LogError(body.TrackingId);
                //}
                //msaw end
            }
        }

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

        // First delete untracked bodies
        foreach (ulong trackingId in knownIds)
        {
            if (!trackedIds.Contains(trackingId))           // msaw edit the next lines
            //if(TrackedBody != trackingId)
            //msaw end
            {
                Destroy(_Bodies[trackingId]);
                _Bodies.Remove(trackingId);
            }
        }
        foreach (var body in BodydataArray)
        {
            if (body == null)
            {
                continue;
            }

            if (body.IsTracked)
            {
                if (!_Bodies.ContainsKey(body.TrackingId))                // msaw edit the next lines
                //if(!_Bodies.ContainsKey(TrackedBody))
                //msaw end
                {
                    _Bodies[body.TrackingId] = CreateBodyObject(body.TrackingId);                     //msaw edit the next lines
                    //_Bodies[TrackedBody] = CreateBodyObject(TrackedBody);
                    // msaw end
                    _MonitorState._Behavior = MonitorState.AI.Awake;
                    print("got tracking so awakening....");
                }

                RefreshBodyObject(body, _Bodies[body.TrackingId]);                  //msaw edit the next lines
                //RefreshBodyObject(body, _Bodies[TrackedBody]);
                //msaw end
                //SET FACE IS CAUSING AN ERROR SOMETIMES

                SetFace(body, _Bodies[body.TrackingId]);                 // msaw edit the next lines
                //SetFace(body, _Bodies[TrackedBody]);
                // msaw end
                SetMovingTarget(body);
                //break; // not shure if break helps to only get one body
            }
        }
        //end body


        // if we captured all faceframes play the animation
        //int lastIndex = FaceFramesArray.Length-1;
        //if (FaceFramesArray[lastIndex]!= null){
        //AnimateFaceFrame();
        //}
        doMonitorBehavior();
    }
Beispiel #2
0
    void Update()
    {
        if (FaceMultiSourceManager == null)
        {
            return;
        }

        _MultiManager = FaceMultiSourceManager.GetComponent<FaceMultiSourceManager>();
        if (_MultiManager == null)
        {
            return;
        }

        if (_Monitor == null)
        {
            return;
        }

        _MonitorState = _Monitor.GetComponent<MonitorState>();
        if (_MonitorState == null)
        {
            return;
        }

        // EXPERIMANTAL depth data imlementation

        //		ushort[] depthData = _MultiManager.GetDepthData();
        //		if (depthData == null)
        //		{
        //			return;
        //		}

        //

        //begin body
        Kinect.Body[] BodydataArray = _MultiManager.GetBodyData ();
        if (BodydataArray == null)
        {
            return;
        }

        List<ulong> trackedIds = new List<ulong>();
        foreach(var body in BodydataArray)
        {
            if (body == null)
            {
                continue;
            }

            if(body.IsTracked)
            {
                trackedIds.Add (body.TrackingId);// msaw edit the next lines
                //if (TrackedBody == 0){
                //	TrackedBody = body.TrackingId;
                    //Debug.LogError(body.TrackingId);
                //}
                //msaw end
            }
        }

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

        // First delete untracked bodies
        foreach(ulong trackingId in knownIds)
        {
            if(!trackedIds.Contains(trackingId))// msaw edit the next lines
            //if(TrackedBody != trackingId)
                //msaw end
            {
                Destroy(_Bodies[trackingId]);
                _Bodies.Remove(trackingId);
            }
        }
        foreach(var body in BodydataArray)
        {
            if (body == null)
            {
                continue;
            }

            if(body.IsTracked)
            {
                if(!_Bodies.ContainsKey(body.TrackingId)) // msaw edit the next lines
                //if(!_Bodies.ContainsKey(TrackedBody))
                //msaw end
                {
                    _Bodies[body.TrackingId] = CreateBodyObject(body.TrackingId); //msaw edit the next lines
                    //_Bodies[TrackedBody] = CreateBodyObject(TrackedBody);
                    // msaw end
                    _MonitorState._Behavior = MonitorState.AI.Awake;
                    print ("got tracking so awakening....");
                }

                 RefreshBodyObject(body, _Bodies[body.TrackingId]); //msaw edit the next lines
                //RefreshBodyObject(body, _Bodies[TrackedBody]);
                //msaw end
                //SET FACE IS CAUSING AN ERROR SOMETIMES

                SetFace(body, _Bodies[body.TrackingId]); // msaw edit the next lines
                //SetFace(body, _Bodies[TrackedBody]);
                // msaw end
                SetMovingTarget(body);
                //break; // not shure if break helps to only get one body
            }
        }
        //end body

        // if we captured all faceframes play the animation
        //int lastIndex = FaceFramesArray.Length-1;
        //if (FaceFramesArray[lastIndex]!= null){
            //AnimateFaceFrame();
        //}
        doMonitorBehavior();
    }
Beispiel #3
0
    void Update()
    {
        if (FaceMultiSourceManager == null)
        {
            return;
        }

        _MultiManager = FaceMultiSourceManager.GetComponent<FaceMultiSourceManager>();
        if (_MultiManager == null)
        {
            return;
        }

        //begin body
        Kinect.Body[] BodydataArray = _MultiManager.GetBodyData ();
        if (BodydataArray == null)
        {
            return;
        }

        List<ulong> trackedIds = new List<ulong>();
        foreach(var body in BodydataArray)
        {
            if (body == null)
            {
                continue;
            }

            if(body.IsTracked)
            {
                trackedIds.Add (body.TrackingId);// msaw edit the next lines
                //if (TrackedBody == 0){
                //	TrackedBody = body.TrackingId;
                //Debug.LogError(body.TrackingId);
                //}
                //msaw end
            }
        }

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

        // First delete untracked bodies
        foreach(ulong trackingId in knownIds)
        {
            if(!trackedIds.Contains(trackingId))// msaw edit the next lines
                //if(TrackedBody != trackingId)
                //msaw end
            {
                Destroy(_Bodies[trackingId]);
                _Bodies.Remove(trackingId);
            }
        }
        foreach(var body in BodydataArray)
        {
            if (body == null)
            {
                continue;
            }

            if(body.IsTracked)
            {
                if(!_Bodies.ContainsKey(body.TrackingId)) // msaw edit the next lines
                    //if(!_Bodies.ContainsKey(TrackedBody))
                    //msaw end
                {
                    _Bodies[body.TrackingId] = CreateBodyObject(body.TrackingId); //msaw edit the next lines
                    //_Bodies[TrackedBody] = CreateBodyObject(TrackedBody);
                    // msaw end
                    print ("got tracking so awakening....");
                }

                RefreshBodyObject(body, _Bodies[body.TrackingId]); //msaw edit the next lines
                //RefreshBodyObject(body, _Bodies[TrackedBody]);
                //msaw end
                //SET FACE IS CAUSING AN ERROR SOMETIMES

                //SetFace(body, _Bodies[body.TrackingId]); // msaw edit the next lines
                //SetFace(body, _Bodies[TrackedBody]);
                // msaw end
                SetMovingTarget(body);
                //break; // not shure if break helps to only get one body
            }
        }
        //end body
    }
Beispiel #4
0
    void Update()
    {
        if (FaceMultiSourceManager == null)
        {
            return;
        }

        _MultiManager = FaceMultiSourceManager.GetComponent <FaceMultiSourceManager>();
        if (_MultiManager == null)
        {
            return;
        }

        //begin body
        Kinect.Body[] BodydataArray = _MultiManager.GetBodyData();
        if (BodydataArray == null)
        {
            return;
        }

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

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

            if (body.IsTracked)
            {
                trackedIds.Add(body.TrackingId);                 // msaw edit the next lines
                //if (TrackedBody == 0){
                //	TrackedBody = body.TrackingId;
                //Debug.LogError(body.TrackingId);
                //}
                //msaw end
            }
        }

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

        // First delete untracked bodies
        foreach (ulong trackingId in knownIds)
        {
            if (!trackedIds.Contains(trackingId))           // msaw edit the next lines
            //if(TrackedBody != trackingId)
            //msaw end
            {
                Destroy(_Bodies[trackingId]);
                _Bodies.Remove(trackingId);
            }
        }
        foreach (var body in BodydataArray)
        {
            if (body == null)
            {
                continue;
            }

            if (body.IsTracked)
            {
                if (!_Bodies.ContainsKey(body.TrackingId))                // msaw edit the next lines
                //if(!_Bodies.ContainsKey(TrackedBody))
                //msaw end
                {
                    _Bodies[body.TrackingId] = CreateBodyObject(body.TrackingId);                     //msaw edit the next lines
                    //_Bodies[TrackedBody] = CreateBodyObject(TrackedBody);
                    // msaw end
                    print("got tracking so awakening....");
                }

                RefreshBodyObject(body, _Bodies[body.TrackingId]);                 //msaw edit the next lines
                //RefreshBodyObject(body, _Bodies[TrackedBody]);
                //msaw end
                //SET FACE IS CAUSING AN ERROR SOMETIMES

                //SetFace(body, _Bodies[body.TrackingId]); // msaw edit the next lines
                //SetFace(body, _Bodies[TrackedBody]);
                // msaw end
                SetMovingTarget(body);
                //break; // not shure if break helps to only get one body
            }
        }
        //end body
    }