/// <summary> /// Start is called before the first frame update /// </summary> void Start() { // Initialize use areas and queue areas for (int i = 0; i < useAreasTransforms.Length; i++) { UseArea temp = new UseArea(useAreasTransforms[i]); useAreas.Add(temp); } for (int i = 0; i < queueAreasTransforms.Length; i++) { queueAreas.Add(new QueueArea(queueAreasTransforms[i])); } queuePlaces = new bool[queueAreasTransforms.Length]; }
public static void SetGestureCondition <T>(T ob, MountType mountType, UseArea useArea, UsingHand usingHand, PalmDirection palmDirection) where T : IGesture { if (ob._gestureType == GestureType.fliphand)// If gesture type is flip hand. { FlipHand_Gesture tempFlipHand = ob as FlipHand_Gesture; /* Initiate gesture option */ tempFlipHand._isChecked = false; /* Initiate to user options. */ tempFlipHand._mountType = mountType; tempFlipHand._useArea = useArea; tempFlipHand._usingHand = usingHand; tempFlipHand._palmDirection = palmDirection; } }
public static void SetGestureCondition <T>(T ob, MountType mountType, UseArea useArea, UsingHand usingHand) where T : IGesture { if (ob._gestureType == GestureType.keytab)// If gesture type is keytab. { KeyTap_Gesture tempKeyTab = ob as KeyTap_Gesture; /* Initiate gesture option */ tempKeyTab._isChecked = false; /* Initiate to user options. */ tempKeyTab._mountType = tempKeyTab.MountType; tempKeyTab._useArea = useArea; tempKeyTab._usingHand = usingHand; } else if (ob._gestureType == GestureType.screentab)// If gesture type is screentab. { ScreenTap_Gesture tempScreenTab = ob as ScreenTap_Gesture; /* Initiate gesture option */ tempScreenTab._isChecked = false; /* Initiate to user options. */ tempScreenTab._useArea = useArea; tempScreenTab._mountType = tempScreenTab.MountType; tempScreenTab._usingHand = usingHand; } else if (ob._gestureType == GestureType.grabhand)// If gesture type is grabbing hand. { GrabHand_Gesture tempGrabHand = ob as GrabHand_Gesture; /* Initiate gesture option */ tempGrabHand._isChecked = false; /* Initiate to user options. */ tempGrabHand._mountType = mountType; tempGrabHand._useArea = useArea; tempGrabHand._usingHand = usingHand; } }
public static void SetGestureCondition <T>(T ob, SwipeDirection swipeDirection, int sensitivity, UseArea useArea, UsingHand usingHand) where T : IGesture { if (ob._gestureType == GestureType.swipe)// If gesture type is swipe. { Swipe_Gesture tempSwipe = ob as Swipe_Gesture; /* Initiate gesture option */ tempSwipe._isChecked = false; tempSwipe._direction = Vector.Zero; tempSwipe._state = Gesture.GestureState.STATE_INVALID; tempSwipe._isPlaying = false; /* Initiate to user options. */ tempSwipe._mountType = tempSwipe.MountType; tempSwipe.Sensitivity = sensitivity; tempSwipe._useArea = useArea; tempSwipe._usingHand = usingHand; //For swipe gesture, this gesture has many direction about mount type. //So, We process this coordinates. if (tempSwipe._mountType == MountType.HeadMount) { if (swipeDirection == SwipeDirection.GoLeft) { tempSwipe.UseAxis = 'x'; tempSwipe._useDirection = 1; } else if (swipeDirection == SwipeDirection.GoRight) { tempSwipe.UseAxis = 'x'; tempSwipe._useDirection = -1; } else if (swipeDirection == SwipeDirection.GoDown) { tempSwipe.UseAxis = 'z'; tempSwipe._useDirection = 1; } else if (swipeDirection == SwipeDirection.GoUp) { tempSwipe.UseAxis = 'z'; tempSwipe._useDirection = -1; } else if (swipeDirection == SwipeDirection.GoStraight) { tempSwipe.UseAxis = 'y'; tempSwipe._useDirection = 1; } else { tempSwipe.UseAxis = 'y'; tempSwipe._useDirection = -1; } } else { if (swipeDirection == SwipeDirection.GoLeft) { tempSwipe.UseAxis = 'x'; tempSwipe._useDirection = -1; } else if (swipeDirection == SwipeDirection.GoRight) { tempSwipe.UseAxis = 'x'; tempSwipe._useDirection = 1; } else if (swipeDirection == SwipeDirection.GoDown) { tempSwipe.UseAxis = 'y'; tempSwipe._useDirection = -1; } else if (swipeDirection == SwipeDirection.GoUp) { tempSwipe.UseAxis = 'y'; tempSwipe._useDirection = 1; } else if (swipeDirection == SwipeDirection.GoStraight) { tempSwipe.UseAxis = 'z'; tempSwipe._useDirection = -1; } else { tempSwipe.UseAxis = 'z'; tempSwipe._useDirection = 1; } } } }
public static void SetGestureCondition <T>(T ob, MountType mountType, CircleDirection circleDirection, float progress, UseArea useArea, UsingHand usingHand) where T : IGesture { if (ob._gestureType == GestureType.circle) // If gesture type is circle. { Circle_Gesture tempCircle = ob as Circle_Gesture; /* Initiate gesture option */ tempCircle._state = Gesture.GestureState.STATE_INVALID; tempCircle._isChecked = false; tempCircle._isClockwise = -1; tempCircle._isPlaying = false; /* Initiate to user options. */ tempCircle._usingHand = usingHand; tempCircle._mountType = mountType; tempCircle._useArea = useArea; tempCircle.MinProgress = progress; if (circleDirection == CircleDirection.Clockwise) { tempCircle._useDirection = 1; } else { tempCircle._useDirection = -1; } } }
//This static method indicates that the gesture is captured on the desired area. public static bool capturedSide(Hand hand, UseArea useArea, MountType mountType) { if (mountType == MountType.TableMount) // If application mount type is table mount. { // left, right : x, up,down : z //Modified coordinate to relative axis of unity camera. Vector position = hand.PalmPosition; Vector3 unityPosition = position.ToUnity(); // Set coordinate value to unity scale. Vector3 toPos = new Vector3(((unityPosition.x + 150.0f) / 300.0f), (unityPosition.y / 300.0f), ((unityPosition.z + 150.0f) / 300.0f)); Vector3 pos = Camera.main.ViewportToWorldPoint(toPos); Vector3 tempos = Camera.main.WorldToViewportPoint(pos);//From now, coordinate values are setted range(0~1) //---------------------------------------------------- // Check condition of using area. switch (useArea) { case UseArea.All: return(true); case UseArea.Left: if (tempos.x < 0.5) { return(true); } else { return(false); } case UseArea.Right: if (tempos.x >= 0.5) { return(true); } else { return(false); } case UseArea.Up: if (tempos.y >= 0.5) { return(true); } else { return(false); } case UseArea.Down: if (tempos.y < 0.5) { return(true); } else { return(false); } default: return(false); } } // If application mount type is head mount. // left, right : x, up,down : y else { //Modified coordinate to relative axis of unity camera. //And change coordinate mode table mount to head mount. Vector position = hand.PalmPosition; Vector3 unityPosition = position.ToUnity(); Vector3 toPos = new Vector3(1 - ((unityPosition.x + 150.0f) / 300.0f), ((unityPosition.z + 150.0f) / 300.0f), (unityPosition.y / 300.0f)); Vector3 pos = Camera.main.ViewportToWorldPoint(toPos); Vector3 tempos = Camera.main.WorldToViewportPoint(pos); //------------------------------------------------------ switch (useArea) { case UseArea.All: return(true); case UseArea.Left: if (tempos.x < 0.5) { return(true); } else { return(false); } case UseArea.Right: if (tempos.x >= 0.5) { return(true); } else { return(false); } case UseArea.Up: if (tempos.y >= 0.5) { return(true); } else { return(false); } case UseArea.Down: if (tempos.y < 0.5) { return(true); } else { return(false); } default: return(false); } } }
//----------------------------------------------------------------------- protected void SetGestureCondition(SwipeDirection swipeDirection, int sensitivity, UseArea useArea) { _gestureType = GestureType.swipe; _leap_controller = ControllerSetter.SetConfig(_gestureType); GestureSetting.SetGestureCondition(this, swipeDirection, sensitivity, useArea, UsingHand); }