Example #1
0
        private bool DoesParentSatisfyRules(ConnectedJoint connectedJoint, List <Joint> skeletonJoints)
        {
            bool satisfyRules = true;

            Joint          thisJoint;
            ConnectedJoint child;

            // Extract this joint. If it's null, the gesture will not be found; return false. Remove
            // this joint from the collection, since it's a parent and will no longer be traversed.
            thisJoint = skeletonJoints.Find(joint => joint.JointType == connectedJoint.JointType);
            if (thisJoint == null)
            {
                return(false);
            }
            skeletonJoints.RemoveAll(joint => joint.JointType == connectedJoint.JointType);

            foreach (Joint joint in skeletonJoints)
            {
                child         = connectedJoints.Find(cj => cj.JointType == joint.JointType);
                satisfyRules &= child != null && connectedJoint.DoesChildMeetGestureRules(child.ID, thisJoint, joint);
                if (!satisfyRules)
                {
                    break;
                }
            }

            if (connectedJoint.NextJoint == null)
            {
                return(satisfyRules);
            }
            else if (!satisfyRules)
            {
                // If false already, exit the traversal.
                return(satisfyRules);
            }
            else
            {
                return(satisfyRules && DoesParentSatisfyRules(connectedJoint.NextJoint, skeletonJoints));
            }
        }
Example #2
0
        private bool DoesParentSatisfyRules(ConnectedJoint connectedJoint, List<Joint> skeletonJoints)
        {
            bool satisfyRules = true;

            Joint thisJoint;
            ConnectedJoint child;

            // Extract this joint. If it's null, the gesture will not be found; return false. Remove
            // this joint from the collection, since it's a parent and will no longer be traversed.
            thisJoint = skeletonJoints.Find(joint => joint.JointType == connectedJoint.JointType);
            if (thisJoint == null) return false;
            skeletonJoints.RemoveAll(joint => joint.JointType == connectedJoint.JointType);

            foreach (Joint joint in skeletonJoints)
            {
                child = connectedJoints.Find(cj => cj.JointType == joint.JointType);
                satisfyRules &= child != null && connectedJoint.DoesChildMeetGestureRules(child.ID, thisJoint, joint);
                if (!satisfyRules) break;
            }

            if (connectedJoint.NextJoint == null)
            {
                return satisfyRules;
            }
            else if(!satisfyRules)
            {
                // If false already, exit the traversal.
                return satisfyRules;
            }
            else
            {
                return satisfyRules && DoesParentSatisfyRules(connectedJoint.NextJoint, skeletonJoints);
            }
        }