Beispiel #1
0
    /// <summary>
    /// Updates the gesture.
    /// </summary>
    /// <param name="data">The skeleton data.</param>
    public void UpdateGesture(BasicAvatarModel data)
    {
        if (this.paused)
        {
            if (this.frameCount == this.pausedFrameCount)
            {
                this.paused = false;
            }

            this.frameCount++;
        }

        GesturePartResult result = this.gestureParts[this.currentGesturePart].CheckGesture(data);

        if (result == GesturePartResult.Succeed)
        {
            // There are still segments of our gesture
            if (this.currentGesturePart + 1 < this.gestureParts.Length)
            {
                // increase the currentGesturePart to check for the next part of the gesture the next time this method is called
                this.currentGesturePart++;
                this.frameCount       = 0;  // reset the frame counter
                this.pausedFrameCount = 10; // make a short break of 10 frames
                this.paused           = true;
            }
            else // Found last segment of the gesture
            {
                if (this.GestureRecognizedInGesture != null) // make sure our event is associated with a method
                {
                    // fire the event
                    // The method to be called is defined in GestureController.cs
                    this.GestureRecognizedInGesture(this, new GestureEventArgs(this.name, data.getTrackingID()));
                    this.Reset();
                }
            }
        }
        else if (result == GesturePartResult.Fail || this.frameCount == 50)
        {
            this.currentGesturePart = 0;
            this.frameCount         = 0;
            this.pausedFrameCount   = 5;
            this.paused             = true;
        }
        else
        {
            this.frameCount++;
            this.pausedFrameCount = 5;
            this.paused           = true;
        }
    }