Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #3
0
        public void Awake()
        {
            this.m_Actor            = GetComponent <KinectActor>();
            this.m_JointTypeToJoint = new KinectSkeletonJoint[KinectHelper.jointTypeCount];
            this.m_Joints           = new KinectSkeletonJoint[KinectHelper.jointTypeCount];
            this.m_SkipRebuild      = false;

            RebuildJointHierarchy();
        }
Beispiel #4
0
        public static bool InArea(this KinectActor actor, Rect area)
        {
            JointType jointType = JointType.SpineMid;

            if (actor.HeadVisible())
            {
                jointType = JointType.Head;
            }

            Vector3 position = actor.GetJointPosition(jointType);

            return(area.Contains(new Vector2(position.x, position.z)));
        }
Beispiel #5
0
        private KinectActor ConstructActor(string name)
        {
            KinectActor actor = null;

            if (this.constructionType == KinectActorConstructionType.Prefab)
            {
                actor      = Instantiate <KinectActor>(prefab, transform);
                actor.name = name;
            }
            else
            {
                actor = new GameObject(name).AddComponent <KinectActor>();
                actor.transform.parent = transform;

                if (this.constructionType == KinectActorConstructionType.Full)
                {
                    var skeleton = actor.gameObject.AddComponent <KinectSkeleton>();
                    skeleton.CreateJointTree(JointType.SpineBase);
                }
            }

            return(actor);
        }
Beispiel #6
0
 public void Awake()
 {
     this.actor = base.GetComponentInChildren <KinectActor>();
     Initialize();
 }
Beispiel #7
0
 public void Awake()
 {
     this.actor = base.GetComponent <KinectActor>();
 }
 public virtual void Start()
 {
     this.actor = KinectPlayArea.Actor;
 }
Beispiel #9
0
 public void Reset()
 {
     this.constructionType = KinectActorConstructionType.Full;
     this.prefab           = null;
 }
 public void OnEnable()
 {
     this.me    = (KinectActor)base.target;
     this.brain = null;
 }
Beispiel #11
0
 public static void DrawGizmos(KinectActor actor, GizmoType type)
 {
     Gizmos.color = KinectEditorUtils.green;
     Gizmos.DrawWireCube(actor.bounds.center, actor.bounds.size);
 }
Beispiel #12
0
 public void OnEnable()
 {
     this.m_Me = (KinectActor)target;
 }