// Method for getting gesture's pointable object. public static Pointable GetPointable <T>(T ob) where T : IGesture { if (ob._gestureType == GestureType.circle) { Circle_Gesture tempCircle = ob as Circle_Gesture; tempCircle._pointable = tempCircle._circle_gesture.Pointable; return(tempCircle._pointable); } else if (ob._gestureType == GestureType.swipe) { Swipe_Gesture tempSwipe = ob as Swipe_Gesture; tempSwipe._pointable = tempSwipe._swipe_gestrue.Pointable; return(tempSwipe._pointable); } else if (ob._gestureType == GestureType.keytab) { KeyTap_Gesture tempKeyTab = ob as KeyTap_Gesture; tempKeyTab._pointable = tempKeyTab._keytab_gesture.Pointable; return(tempKeyTab._pointable); } else if (ob._gestureType == GestureType.screentab) { ScreenTap_Gesture tempScreenTab = ob as ScreenTap_Gesture; tempScreenTab._pointable = tempScreenTab._screentap_gesture.Pointable; return(tempScreenTab._pointable); } else { return(new Pointable()); } }
// Someone who may also be required where it originated gesture. // If you use this value, possibility arise up about new gesture of another pattern. public static Vector GetGestureInvokePosition <T>(T ob) where T : IGesture { if (ob._gestureType == GestureType.swipe) { Swipe_Gesture tempSwipe = ob as Swipe_Gesture; if (tempSwipe._swipe_gestrue != null) { tempSwipe._position = tempSwipe._swipe_gestrue.Position; return(tempSwipe._position); } } else if (ob._gestureType == GestureType.keytab) { KeyTap_Gesture tempKeyTab = ob as KeyTap_Gesture; if (tempKeyTab._keytab_gesture != null) { tempKeyTab._position = tempKeyTab._keytab_gesture.Position; return(tempKeyTab._position); } } else if (ob._gestureType == GestureType.screentab) { ScreenTap_Gesture tempScreenTab = ob as ScreenTap_Gesture; if (tempScreenTab._screentap_gesture != null) { tempScreenTab._position = tempScreenTab._screentap_gesture.Position; return(tempScreenTab._position); } } return(new Vector(0, 0, 0)); }
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; } }
// This method check whether hand user want to use direction is captured. public static bool IsEnableGestureHand <T>(T ob) where T : IGesture { switch (ob._gestureType) // Check the gesture type. { case GestureType.swipe: // If GestureType is swipe. Swipe_Gesture tempSwipe = ob as Swipe_Gesture; // Wrap gesture type. if (tempSwipe._usingHand == UsingHand.All) // If UsingHand value is All. { return(true); } else if ((tempSwipe._usingHand == UsingHand.Left) && (tempSwipe.tempHand.IsLeft)) //If UsingHand value is Left and captured hand side is left. { return(true); } else if ((tempSwipe._usingHand == UsingHand.Right) && tempSwipe.tempHand.IsRight) //If UsingHand value is Right and captured hand side is Right. { return(true); } return(false); case GestureType.circle: // If GestureType is circle. Circle_Gesture tempCircle = ob as Circle_Gesture; if (tempCircle._usingHand == UsingHand.All) { return(true); } else if ((tempCircle._usingHand == UsingHand.Left) && (tempCircle.tempHand.IsLeft)) { return(true); } else if ((tempCircle._usingHand == UsingHand.Right) && tempCircle.tempHand.IsRight) { return(true); } return(false); case GestureType.keytab: // If GestureType is keytab. KeyTap_Gesture tempKeytab = ob as KeyTap_Gesture; if (tempKeytab._usingHand == UsingHand.All) { return(true); } else if ((tempKeytab._usingHand == UsingHand.Left) && (tempKeytab.tempHand.IsLeft)) { return(true); } else if ((tempKeytab._usingHand == UsingHand.Right) && tempKeytab.tempHand.IsRight) { return(true); } return(false); case GestureType.screentab: // If GestureType is screentab. ScreenTap_Gesture tempScreenTab = ob as ScreenTap_Gesture; if (tempScreenTab._usingHand == UsingHand.All) { return(true); } else if ((tempScreenTab._usingHand == UsingHand.Left) && (tempScreenTab.tempHand.IsLeft)) { return(true); } else if ((tempScreenTab._usingHand == UsingHand.Right) && tempScreenTab.tempHand.IsRight) { return(true); } return(false); case GestureType.grabhand: // If GestureType is grabbing hand. GrabHand_Gesture tempGrabHand = ob as GrabHand_Gesture; if (tempGrabHand._usingHand == UsingHand.All) { return(true); } else if ((tempGrabHand._usingHand == UsingHand.Left) && tempGrabHand.tempHand.IsLeft) { return(true); } else if ((tempGrabHand._usingHand == UsingHand.Right) && tempGrabHand.tempHand.IsRight) { return(true); } return(false); case GestureType.fliphand: // If GestureType is fliphand. FlipHand_Gesture tempFlipHand = ob as FlipHand_Gesture; if (tempFlipHand._usingHand == UsingHand.All) { return(true); } else if ((tempFlipHand._usingHand == UsingHand.Left) && (tempFlipHand.tempHand.IsLeft)) { return(true); } else if ((tempFlipHand._usingHand == UsingHand.Right) && (tempFlipHand.tempHand.IsRight)) { return(true); } return(false); case GestureType.usercustom: // If GestureType is user custom. UserGesture tempUser = ob as UserGesture; if (tempUser._usingHand == UsingHand.All) { return(true); } else if ((tempUser._usingHand == UsingHand.Left) && (tempUser.tempHand.IsLeft)) { return(true); } else if ((tempUser._usingHand == UsingHand.Right) && (tempUser.tempHand.IsRight)) { return(true); } return(false); default: return(false); } }
//This static method is calculate gesture's direction. //We provide only base vector of x,y,z axis. //If you want to get more complicated value, modify this method or define new method in your gesture script. public static Vector GetDirection <T>(T ob) where T : IGesture { if (ob._gestureType == GestureType.swipe) { Swipe_Gesture temp = ob as Swipe_Gesture; if (temp._swipe_gestrue != null)// If gesture instance is valid. { Vector tempDirection = temp._swipe_gestrue.Direction; float x = Mathf.Abs(tempDirection.x); float y = Mathf.Abs(tempDirection.y); float z = Mathf.Abs(tempDirection.z); if (x > y && x > z) { if (tempDirection.x > 0) { temp._direction = new Vector(1, 0, 0); } else if (tempDirection.x < 0) { temp._direction = new Vector(-1, 0, 0); } } else if (y > x && y > z) { if (tempDirection.x > 0) { temp._direction = new Vector(0, 1, 0); } else if (tempDirection.x < 0) { temp._direction = new Vector(0, -1, 0); } } else if (z > x && z > y) { if (tempDirection.x > 0) { temp._direction = new Vector(0, 0, 1); } else if (tempDirection.x < 0) { temp._direction = new Vector(0, 0, -1); } } return(temp._direction); } else//If gesture instance is not valid of other error, return zero vector. { return(new Vector(0, 0, 0)); } } else if (ob._gestureType == GestureType.keytab) { KeyTap_Gesture temp = ob as KeyTap_Gesture; if (temp._keytab_gesture != null) { Vector tempDirection = temp._keytab_gesture.Direction; float x = Mathf.Abs(tempDirection.x); float y = Mathf.Abs(tempDirection.y); float z = Mathf.Abs(tempDirection.z); if (x > y && x > z) { if (tempDirection.x > 0) { temp._direction = new Vector(1, 0, 0); } else if (tempDirection.x < 0) { temp._direction = new Vector(-1, 0, 0); } } else if (y > x && y > z) { if (tempDirection.y > 0) { temp._direction = new Vector(0, 1, 0); } else if (tempDirection.y < 0) { temp._direction = new Vector(0, -1, 0); } } else if (z > x && z > y) { if (tempDirection.z > 0) { temp._direction = new Vector(0, 0, 1); } else if (tempDirection.z < 0) { temp._direction = new Vector(0, 0, -1); } } return(temp._direction); } else { return(new Vector(0, 0, 0)); } } else if (ob._gestureType == GestureType.screentab) { ScreenTap_Gesture temp = ob as ScreenTap_Gesture; if (temp._screentap_gesture != null) { Vector tempDirection = temp._screentap_gesture.Direction; float x = Mathf.Abs(tempDirection.x); float y = Mathf.Abs(tempDirection.y); float z = Mathf.Abs(tempDirection.z); if (x > y && x > z) { if (tempDirection.x > 0) { temp._direction = new Vector(1, 0, 0); } else if (tempDirection.x < 0) { temp._direction = new Vector(-1, 0, 0); } } else if (y > x && y > z) { if (tempDirection.x > 0) { temp._direction = new Vector(0, 1, 0); } else if (tempDirection.x < 0) { temp._direction = new Vector(0, -1, 0); } } else if (z > x && z > y) { if (tempDirection.x > 0) { temp._direction = new Vector(0, 0, 1); } else if (tempDirection.x < 0) { temp._direction = new Vector(0, 0, -1); } } return(temp._direction); } else { return(new Vector(0, 0, 0)); } } else { return(new Vector(0, 0, 0));//I } }