Esempio n. 1
0
        public static void ClosestToPoint(this KinectActor actor, Body[] bodies, UnityEngine.Vector3 point, JointType jointType = JointType.Head)
        {
            float distance = float.PositiveInfinity;
            int   index    = -1;

            for (int i = bodies.Length - 1; i >= 0; --i)
            {
                if (!bodies[i].IsTracked)
                {
                    continue;
                }

                Vector3 position = bodies[i].JointPositionRealSpace(jointType, KinectActor.CoordinateOrigin, actor.Floor);
                float   sqr      = (position - point).sqrMagnitude;

                if (sqr < distance)
                {
                    distance = sqr;
                    index    = i;
                }
            }

            if (index >= 0)
            {
                actor.Refresh(index);
            }
        }
Esempio n. 2
0
        public static void FindTallest(this KinectActor actor, Body[] bodies)
        {
            float z     = 0f;
            int   index = -1;

            for (int i = bodies.Length - 1; i >= 0; --i)
            {
                if (!bodies[i].IsTracked)
                {
                    continue;
                }

                Vector3 position = bodies[i].JointPositionRealSpace(JointType.Head, KinectActor.CoordinateOrigin, actor.Floor);

                if (position.z > z)
                {
                    z     = position.z;
                    index = i;
                }
            }

            if (index >= 0)
            {
                actor.Refresh(index);
            }
        }