示例#1
0
文件: LeapManager.cs 项目: Krewn/LIOS
    // resets the gesture-data state for the given extra gesture
    public bool ResetGesture(LeapExtraGestures.ExtraGestures gesture)
    {
        int index = GetGestureIndex(gesture);
        if(index < 0)
            return false;

        LeapExtraGestures.ExtraGestureData gestureData = extraGesturesData[index];

        gestureData.state = 0;
        gestureData.jointId = 0;
        gestureData.progress = 0f;
        gestureData.complete = false;
        gestureData.cancelled = false;
        gestureData.startTrackingAtTime = Time.realtimeSinceStartup + LeapExtraGestures.Constants.MinTimeBetweenGestures;

        extraGesturesData[index] = gestureData;

        return true;
    }
示例#2
0
文件: LeapManager.cs 项目: Krewn/LIOS
    // return the index of extra gesture in the list, or -1 if not found
    private int GetGestureIndex(LeapExtraGestures.ExtraGestures gesture)
    {
        int listSize = extraGesturesData.Count;

        for(int i = 0; i < listSize; i++)
        {
            if(extraGesturesData[i].gesture == gesture)
                return i;
        }

        return -1;
    }
示例#3
0
文件: LeapManager.cs 项目: Krewn/LIOS
    // returns true, if the given extra gesture is complete
    public bool IsGestureComplete(LeapExtraGestures.ExtraGestures gesture, bool bResetOnComplete)
    {
        int index = GetGestureIndex(gesture);

        if(index >= 0)
        {
            LeapExtraGestures.ExtraGestureData gestureData = extraGesturesData[index];

            if(bResetOnComplete && gestureData.complete)
            {
                ResetGesture(gesture);
                return true;
            }

            return gestureData.complete;
        }

        return false;
    }
示例#4
0
文件: LeapManager.cs 项目: Krewn/LIOS
 // returns true, if the given extra gesture is in the list of detected extra gestures
 public bool IsGestureDetected(LeapExtraGestures.ExtraGestures gesture)
 {
     int index = GetGestureIndex(gesture);
     return index >= 0;
 }
示例#5
0
文件: LeapManager.cs 项目: Krewn/LIOS
    // returns the normalized velocity of the given extra gesture
    public Vector3 GetGestureVelocity(LeapExtraGestures.ExtraGestures gesture)
    {
        int index = GetGestureIndex(gesture);

        if(index >= 0)
        {
            LeapExtraGestures.ExtraGestureData gestureData = extraGesturesData[index];

            if(gestureData.completeTime > 0)
            {
                Vector3 gestureVel = gestureData.gestureDir / gestureData.completeTime;
                return gestureVel.normalized;
            }
        }

        return Vector3.zero;
    }
示例#6
0
文件: LeapManager.cs 项目: Krewn/LIOS
    // returns true, if the given extra gesture is cancelled
    public bool IsGestureCancelled(LeapExtraGestures.ExtraGestures gesture)
    {
        int index = GetGestureIndex(gesture);

        if(index >= 0)
        {
            LeapExtraGestures.ExtraGestureData gestureData = extraGesturesData[index];
            return gestureData.cancelled;
        }

        return false;
    }
示例#7
0
文件: LeapManager.cs 项目: Krewn/LIOS
    // returns the normalized screen position of the given extra gesture
    public Vector3 GetGestureScreenPos(LeapExtraGestures.ExtraGestures gesture)
    {
        int index = GetGestureIndex(gesture);

        if(index >= 0)
        {
            LeapExtraGestures.ExtraGestureData gestureData = extraGesturesData[index];
            return gestureData.screenPos;
        }

        return Vector3.zero;
    }
示例#8
0
文件: LeapManager.cs 项目: Krewn/LIOS
    // returns the progress in range [0, 1] of the given extra gesture
    public float GetGestureProgress(LeapExtraGestures.ExtraGestures gesture)
    {
        int index = GetGestureIndex(gesture);

        if(index >= 0)
        {
            LeapExtraGestures.ExtraGestureData gestureData = extraGesturesData[index];
            return gestureData.progress;
        }

        return 0f;
    }
示例#9
0
文件: LeapManager.cs 项目: Krewn/LIOS
    // returns the normalized direction of the given extra gesture
    public Vector3 GetGestureDirection(LeapExtraGestures.ExtraGestures gesture)
    {
        int index = GetGestureIndex(gesture);

        if(index >= 0)
        {
            LeapExtraGestures.ExtraGestureData gestureData = extraGesturesData[index];
            return gestureData.gestureDir.normalized;
        }

        return Vector3.zero;
    }
示例#10
0
文件: LeapManager.cs 项目: Krewn/LIOS
    // adds a gesture to the list of detected extra gestures
    public void DetectGesture(LeapExtraGestures.ExtraGestures gesture)
    {
        int index = GetGestureIndex(gesture);
        if(index >= 0)
            DeleteGesture(gesture);

        LeapExtraGestures.ExtraGestureData gestureData = new LeapExtraGestures.ExtraGestureData();

        gestureData.gesture = gesture;
        gestureData.state = 0;
        gestureData.jointId = 0;
        gestureData.progress = 0f;
        gestureData.complete = false;
        gestureData.cancelled = false;

        extraGesturesData.Add(gestureData);
    }
示例#11
0
文件: LeapManager.cs 项目: Krewn/LIOS
    // deletes the given gesture from the list of detected extra gestures
    public bool DeleteGesture(LeapExtraGestures.ExtraGestures gesture)
    {
        int index = GetGestureIndex(gesture);
        if(index < 0)
            return false;

        extraGesturesData.RemoveAt(index);
        return true;
    }