示例#1
0
        public void Initialize()
        {
            currentLibrary = null;
            currentGesture = null;

            libraryListMenu = new GenericMenu();
            gestureListMenu = new GenericMenu();
            gestureMenu     = new GenericMenu();

            libraryListMenu.AddItem(new GUIContent("Add gesture library"), false, OnClickAddGestureLibrary);
            gestureListMenu.AddItem(new GUIContent("Add gesture"), false, OnClickAddGesture);
            gestureMenu.AddItem(new GUIContent("Remove"), false, OnClickRemoveGesture);
            gestureMenu.AddItem(new GUIContent("Rename"), false, OnClickRenameGesture);

            resizerStyle = new GUIStyle();
            resizerStyle.normal.background = EditorGUIUtility.Load("icons/d_AvatarBlendBackground.png") as Texture2D;

            if (EditorGUIUtility.isProSkin)
            {
                skin = EditorGUIUtility.Load("GUISkins/GestureEditorProSkin.guiskin") as GUISkin;
            }
            else
            {
                skin = EditorGUIUtility.Load("GUISkins/GestureEditorSkin.guiskin") as GUISkin;
            }

            newGestureName  = "";
            isAddingGesture = false;
            points          = new List <Point>();
            lastPoint       = Vector2.zero;
            strokeID        = -1;
        }
示例#2
0
 void Start()
 {
     gl = new GestureLibrary(libraryToLoad);
     player = GameObject.Find("Player");
     gestureLineRenderer = GetComponent<LineRenderer>();
     levelController = GetComponent<_LevelController>();
 }
        /// <summary>
        /// Recognize the gesture by comparing it to every single gesture in the library,
        /// scoring them and finding the highest score. Don't recognize the gesture if there
        /// is less than 2 points.
        ///
        /// There are two algorithms to recognize a gesture: $1 and Protractor. $1 is slower
        /// compared to Protractor, however, $1 provides a scoring system in [0, 1] interval
        /// which is very useful to determine "how much" the captured gesture looks like the
        /// library gesture.
        ///
        /// To find out more about the algorithms and how they work, see the respective method
        /// comments.
        /// </summary>
        /// <param name="gestureLibrary">The library to run the gesture against.</param>
        /// <param name="useProtractor">If this is true, the faster Protractor algorithm will be used.</param>
        /// <returns>Recognized gesture's name and its score</returns>
        public Result Recognize(GestureLibrary gestureLibrary, out Gesture recognizedGesture, bool useProtractor = false)
        {
            //this function return the recognized gesture
            recognizedGesture = null;
            if (this.Points.Count <= 2)
            {
                return(new Result("Not enough points captured", 0f));
            }
            else
            {
                List <Gesture> library = gestureLibrary.Library;

                float bestDistance   = float.MaxValue;
                int   matchedGesture = -1;

                // Match the gesture against all the gestures in the library
                for (int i = 0; i < library.Count; i++)
                {
                    float distance = 0;

                    if (useProtractor)
                    {
                        // See ProtractorAlgorithm() method's comments to find out more about it.
                        distance = ProtractorAlgorithm(library[i].Vector, this.Vector);
                    }
                    else
                    {
                        // See DollarOneAlgorithm() method's comments to find out more about it.
                        distance = DollarOneAlgorithm(library[i], -this.ANGLE_RANGE, +this.ANGLE_RANGE, this.ANGLE_PRECISION);
                    }

                    // If distance is better than the best distance take it as the best distance,
                    // and gesture as the recognized one.
                    if (distance < bestDistance)
                    {
                        bestDistance   = distance;
                        matchedGesture = i;
                    }
                }

                // No match, score zero. If there is a match, send the name of the recognized gesture and a score.
                if (matchedGesture == -1)
                {
                    return(new Result("No match", 0f));
                }
                else
                {
                    recognizedGesture = library[matchedGesture];
                    return(new Result(library[matchedGesture].Name, useProtractor ? 1f / bestDistance : 1f - bestDistance / this.HALF_DIAGONAL));
                }
            }
        }
示例#4
0
 private void SetCurrentLibrary()
 {
     if (Selection.activeObject != null && Selection.activeObject.GetType() == typeof(GestureLibrary))
     {
         currentLibrary = (GestureLibrary)Selection.activeObject;
         currentGesture = null;
     }
     else
     {
         if (!isLocked)
         {
             currentLibrary = null;
             currentGesture = null;
         }
     }
 }
 // Load the library.
 void Start()
 {
     gl = new GestureLibrary(libraryToLoad, forceCopy);
 }
示例#6
0
    // Load the library.
    void Start()
    {
        gl = new GestureLibrary(libraryToLoad, forceCopy);

        if (gestureLimitType == GestureLimitType.RectBoundsClamp) {
            parentCanvas = gestureLimitRectBounds.GetComponentInParent<Canvas>();
            gestureLimitRect = RectTransformUtility.PixelAdjustRect(gestureLimitRectBounds, parentCanvas);
            gestureLimitRect.position += new Vector2(gestureLimitRectBounds.position.x, gestureLimitRectBounds.position.y);
        }
    }
示例#7
0
        /// <summary>
        /// Recognize the gesture by comparing it to every single gesture in the library,
        /// scoring them and finding the highest score. Don't recognize the gesture if there
        /// is less than 2 points.
        /// 
        /// There are two algorithms to recognize a gesture: $1 and Protractor. $1 is slower
        /// compared to Protractor, however, $1 provides a scoring system in [0, 1] interval
        /// which is very useful to determine "how much" the captured gesture looks like the 
        /// library gesture.
        /// 
        /// To find out more about the algorithms and how they work, see the respective method
        /// comments.
        /// </summary>
        /// <param name="gestureLibrary">The library to run the gesture against.</param>
        /// <param name="useProtractor">If this is true, the faster Protractor algorithm will be used.</param>
        /// <returns>Recognized gesture's name and its score</returns>
        public Result Recognize(GestureLibrary gestureLibrary, bool useProtractor = false)
        {
            if (this.Points.Count <= 2) {
                return new Result("Not enough points captured", 0f);
            } else {
                List<Gesture> library = gestureLibrary.Library;

                float bestDistance = float.MaxValue;
                int matchedGesture = -1;

                // Match the gesture against all the gestures in the library
                for (int i = 0; i < library.Count; i++) {

                    float distance = 0;

                    if (useProtractor) {
                        // See ProtractorAlgorithm() method's comments to find out more about it.
                        distance = ProtractorAlgorithm(library[i].Vector, this.Vector);
                    } else {
                        // See DollarOneAlgorithm() method's comments to find out more about it.
                        distance = DollarOneAlgorithm(library[i], -this.ANGLE_RANGE, +this.ANGLE_RANGE, this.ANGLE_PRECISION);
                    }

                    // If distance is better than the best distance take it as the best distance,
                    // and gesture as the recognized one.
                    if (distance < bestDistance) {
                        bestDistance = distance;
                        matchedGesture = i;
                    }
                }

                // No match, score zero. If there is a match, send the name of the recognized gesture and a score.
                if (matchedGesture == -1) {
                    return new Result("No match", 0f);
                } else {
                    return new Result(library[matchedGesture].Name, useProtractor ? 1f / bestDistance : 1f - bestDistance / this.HALF_DIAGONAL);
                }
            }
        }
 // Load the library.
 void Start()
 {
     gl = new GestureLibrary(libraryToLoad, forceCopy);
     //lineForShowWhatToDraw.enabled = false;
     rand = new System.Random();
     //Debug.Log("Я стартанул");
     inInShowingState = false;
     //StartCoroutine("ShowFiguresFromLibrary");
 }
示例#9
0
 // Load the library.
 void Start()
 {
     gl = new GestureLibrary(libraryToLoad, forceCopy);
     drawArea = new Rect(0, 0, Screen.width - 370, Screen.height);
     //width - 370, height
 }