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, 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, 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; } } }
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; } }
private void Update() { CheckHandSlider(LeftHand); CheckHandSlider(RightHand); if (LeftHand.inContact && MenuSliderHand != UsingHand.rightHand) { MenuSliderHand = UsingHand.leftHand; } else if (RightHand.inContact && MenuSliderHand != UsingHand.leftHand) { MenuSliderHand = UsingHand.rightHand; } else { MenuSliderHand = UsingHand.noHand; } if (MenuSliderHand != UsingHand.noHand) { HandContact HandTouch = new HandContact(); if (MenuSliderHand == UsingHand.leftHand) { HandTouch = LeftHand; } else if (MenuSliderHand == UsingHand.rightHand) { HandTouch = RightHand; } float ContactAngle = HandTouch.contactAngle; if (!MovingMenuSlider) { MovingMenuSlider = true; PreContactMenuSlider = MenuSlider; } else { MenuSlider = PreContactMenuSlider + ContactAngle / 18; } } else { MovingMenuSlider = false; } /* * SliderVelocity = Input.GetAxis("Horizontal")/5; * * SliderVelocity = Mathf.Lerp(SliderVelocity, 0, Time.deltaTime*(10/SliderVelocity)); * * MenuSlider += SliderVelocity;*/ if (MenuSlider < 0) { MenuSlider = 0; } else if (MenuSlider > AlbumTiles.Length - 1) { MenuSlider = AlbumTiles.Length - 1; } currentlySelected = (int)(MenuSlider + 0.5f); if (!LeftHand.inContact && !RightHand.inContact) { MenuSlider = Mathf.Lerp(MenuSlider, currentlySelected, Time.deltaTime * 5); } float ConvertToRadians = (Mathf.PI / 180f); float selectedAngle = (startangle - transform.eulerAngles.y) * ConvertToRadians; for (int i = 0; i < AlbumTiles.Length; i++) { float TileOffsetRad = TileOffsetDegrees * ConvertToRadians; float radRotationY = transform.eulerAngles.y * ConvertToRadians; //Debug.Log("rad" + TileOffsetRad); float angleRad = TileOffsetRad * i - MenuSlider * TileOffsetRad; angleRad -= radRotationY; /* * angleRad *= 180f / Mathf.PI; * * angleRad -= transform.eulerAngles.y; * * angleRad *= (Mathf.PI / 180f);*/ float transparency = 1 - Mathf.Abs(MenuSlider - i) / 4f; float ScaleValue = MenuRadius; if (transparency < 0) { transparency = 0; } if (i == currentlySelected) { ScaleValue = 1.5f * MenuRadius; transparency = 1; angleRad = selectedAngle; } AlbumTiles[i].AlbumObject.transform.position = new Vector3(transform.position.x + MenuRadius * Mathf.Cos(angleRad), transform.position.y, transform.position.z + MenuRadius * Mathf.Sin(angleRad)); AlbumTiles[i].AlbumMat.material.color = new Color(1, 1, 1, transparency); AlbumTiles[i].AlbumObject.transform.LookAt(transform); AlbumTiles[i].AlbumObject.transform.localScale = Vector3.Lerp(AlbumTiles[i].AlbumObject.transform.localScale, Vector3.one * ScaleValue, Time.deltaTime * 5); if (transparency == 0) { AlbumTiles[i].AlbumMat.enabled = false; } else if (!AlbumTiles[i].AlbumMat.enabled) { AlbumTiles[i].AlbumMat.enabled = true; } } //AlbumTiles[currentlySelected].AlbumObject.transform.localPosition += AlbumTiles[currentlySelected].AlbumObject.transform.forward * 0.08f * MenuRadius; AlbumTiles[currentlySelected].AlbumObject.transform.position += AlbumTiles[currentlySelected].AlbumObject.transform.forward * 0.08f * MenuRadius; //AlbumTiles[currentlySelected].AlbumObject.transform.localPosition += -transform.right * 0.08f * MenuRadius; }