Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        floorClipPlane = _BodyManager.GetFloorClipPlane();
        Vector3 InNormal      = new Vector3(floorClipPlane.X, floorClipPlane.Y, floorClipPlane.Z);
        float   floorDistance = floorClipPlane.W;
        float   tiltAngle     = (float)(Math.Atan(InNormal.z / InNormal.y) * (180.0 / Math.PI));

        transform.position = new Vector3(0, 0 - (floorClipPlane.W), 0);

        transform.rotation = Quaternion.AngleAxis(tiltAngle, Vector3.down);
    }
Exemplo n.º 2
0
    void Update()
    {
        if (BodySourceManager == null)
        {
            return;
        }

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

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

        floorClipPlane = _BodyManager.GetFloorClipPlane();

        Vector3 InNormal      = new Vector3(floorClipPlane.X, floorClipPlane.Y, floorClipPlane.Z);
        float   floorDistance = floorClipPlane.W;
        float   tiltAngle     = (float)(Math.Atan(InNormal.z / InNormal.y) * (180.0 / Math.PI));

        ground.transform.position = new Vector3(0, 0 - (floorClipPlane.W * YHumanScalingFactor), 0);
        //ground.transform.position = new Vector3(0, foot.transform.position.y, 0);
        //winText.text = floorClipPlane.W + "-" + tiltAngle;

        ground.transform.rotation = Quaternion.AngleAxis(tiltAngle, Vector3.down);


        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);
            }
        }

        int i = 0;

        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], TextArr[i % 2]);
            }
            i++;
        }
    }