Beispiel #1
0
    public void LoadPersistantGesuture(string name, OnGestureSuccessEvent onSuccess, OnGestureFailureEvent onFail = null, bool loops = true, float loopDelay = 0.1f, float minVelMag = 0.25f)
    {
        List <Vector3> leftMP, rightMP;

        //Try loading the gesture, return on failure
        if (!GestureInput.instance.TryLoadGesture(name, out leftMP, out rightMP))
        {
            return;
        }

        //Add new points to the pool if needed
        int used = PersistantTrackersCount();
        int add  = leftMP.Count + rightMP.Count;

        if (used + add > m_PointsPool.Count)
        {
            CreateTrackers(used + add - m_PointsPool.Count);
        }

        //Align the points
        m_LastActiveIndex = used;
        AlignPoints(ref leftMP, out m_PointTrackersLeft, true);
        AlignPoints(ref rightMP, out m_PointTrackersRight, false);

        //Associate to the gesture tracker
        m_TrackedGestures[name] = new GestureTracker();
        m_TrackedGestures[name].SetUpGestureTracking(name, m_PointTrackersLeft, m_PointTrackersRight, onSuccess, onFail, loops, loopDelay, minVelMag);
    }
    public void LoadAndUseGesture(string name, OnGestureSuccessEvent successEvent, OnGestureFailureEvent failureEvent = null)
    {
        //Try to load the gesture from the library
        if (!m_GestureLib.GetGesture(name, out m_LeftMotionPoints, out m_RightMotionPoints))
        {
            return;
        }

        TransformPointsToCameraSpace(ref m_LeftMotionPoints);
        TransformPointsToCameraSpace(ref m_RightMotionPoints);

        //CreateAllTrackedPoints();
        GestureDetector.instance.SetupTrackers(ref m_LeftMotionPoints, ref m_RightMotionPoints);
        GestureDetector.instance.SetupEvents(successEvent, failureEvent);
        GestureDetector.instance.StartTracking();
    }
    public void SetUpGestureTracking(string gestureName,
                                     List <PointTracker> trackersLeft, List <PointTracker> trackersRight,
                                     OnGestureSuccessEvent successEvent, OnGestureFailureEvent failureEvent = null,
                                     bool loop = true, float loopDelay = 0.1f, float velMagMin = 0.25f)
    {
        m_GestureName         = gestureName;
        m_TrackersLeftHand    = trackersLeft;
        m_TrackersRightHand   = trackersRight;
        m_GestureSuccessEvent = successEvent;
        m_GestureFailureEvent = failureEvent;
        m_Loop      = loop;
        m_LoopDelay = loopDelay;
        m_VelMagMin = velMagMin;

        foreach (PointTracker pt in m_TrackersLeftHand)
        {
            pt.SetOwner(this);
        }

        foreach (PointTracker pt in m_TrackersRightHand)
        {
            pt.SetOwner(this);
        }
    }
Beispiel #4
0
 public void SetupEvents(OnGestureSuccessEvent success, OnGestureFailureEvent failure = null)
 {
     m_SuccessEvent = success;
     m_FailureEvent = failure;
 }