public void TurnOff() { StopAllCoroutines(); controlTarget = null; cameraTarget = null; curGesture = GestureControl.NoTouch; }
/// <summary> /// Reset the grab system. /// </summary> public void Reset() { GameObject gobj = GameObject.Find("Hand_l"); if (gobj != null) { m_tLeftHand = gobj.transform; m_gcLeftHand = gobj.GetComponent <GestureControl>(); } gobj = GameObject.Find("Hand_r"); if (gobj != null) { m_tRightHand = gobj.transform; m_gcRightHand = gobj.GetComponent <GestureControl>(); } if (m_leftHandQueue != null) { m_leftHandQueue.Clear(); } m_leftHandQueue = new List <Grabable>(); if (m_rightHandQueue != null) { m_rightHandQueue.Clear(); } m_rightHandQueue = new List <Grabable>(); m_grabInfo = new GrabManipulationInfo(); m_regrabCooldown = -1f; }
// Start is called before the first frame update void Start() { CreateMenu.SetActive(false); ManiMenu.SetActive(false); ObjMenu.SetActive(false); ActiveIndex = ActiveHand.transform.GetChild(1).GetChild(2).gameObject; ActivePalm = ActiveHand.transform.GetChild(5).GetChild(0).gameObject; ActiveGC = ActiveHand.GetComponent <GestureControl>(); // creation renderers //_creationRenderers.Add(CubeRenderer); //_creationRenderers.Add(CylinderRenderer); //_creationRenderers.Add(ConeRenderer); //_creationRenderers.Add(SphereRenderer); _createMenuParent = CreateMenu.GetComponent <FoamRadialMenuParent>(); // manipulationRenderers //_manipulateRenderers.Add(ManiUppRenderer); //_manipulateRenderers.Add(ManiRightRenderer); //_manipulateRenderers.Add(ManiLowRenderer); //_manipulateRenderers.Add(ManiLeftRenderer); _maniMenuParent = ManiMenu.GetComponent <FoamRadialMenuParent>(); _objCreatedPos = Vector3.zero; _objManiOGColor = FoamMaterial.color; }
private void ToggleGestureTipsControlAnimation(bool show, int delayMillis = 0) { var visual = GestureControl.GetVisual(); visual.Opacity = show ? 0f : 1f; GestureControl.Visibility = Visibility.Visible; var anim = _compositor.CreateScalarKeyFrameAnimation(); anim.Duration = TimeSpan.FromMilliseconds(500); anim.InsertKeyFrame(1f, show ? 1f : 0f); anim.DelayTime = TimeSpan.FromMilliseconds(delayMillis); var batch = _compositor.CreateScopedBatch(CompositionBatchTypes.Animation); batch.Completed += (s, e) => { if (!show) { GestureControl.StopAnimation(); GestureControl.Visibility = Visibility.Collapsed; } else { GestureControl.StartAnimation(); } }; visual.StartAnimation("Opacity", anim); batch.End(); }
protected override void Start() { base.Start(); // move things below to m_data m_leftGC = m_leftHand.GetComponent <GestureControl>(); m_rightGC = m_rightHand.GetComponent <GestureControl>(); m_jui = JUIController.GetComponent <JUIController>(); m_activeGC = m_rightGC; m_activeHand = m_rightHand; _activeIndex = m_activeHand.transform.GetChild(1).GetChild(2).gameObject; _activeThumb = m_activeHand.transform.GetChild(0).GetChild(2).gameObject; //state machine m_stateMachine = this.GetComponent <Animator>(); m_uiState_hashes.Add(m_hash_idleBool); m_uiState_hashes.Add(m_hash_createBool); m_uiState_hashes.Add(m_hash_maniBool); m_data.StateMachine = m_stateMachine; FoamUtils.IsExcludingSelectedObj = false; FoamUtils.IsGlobalGrabbing = false; _JUIGestureAnimator = JUIController.GetComponent <Animator>(); }
private float _nearDis = 0.1f; // to be adjusted based on user preference. near distance to be reached // Start is called before the first frame update void Start() { _focusedObjects = new List <GameObject>(); _activeIndex = ActiveHand.transform.GetChild(1).GetChild(2).gameObject; _activeThumb = ActiveHand.transform.GetChild(0).GetChild(2).gameObject; _activePalm = ActiveHand.transform.GetChild(5).GetChild(0).gameObject; _activeGC = ActiveHand.GetComponent <GestureControl>(); }
void Awake() { gestureControl = gameObject.GetComponent(typeof(GestureControl)) as GestureControl; anim = gameObject.GetComponentInChildren(typeof(Animator)) as Animator; gestures = Resources.LoadAll("Gestures", typeof(AnimationClip)); animatorOverrideController = new AnimatorOverrideController(); animatorOverrideController.runtimeAnimatorController = anim.runtimeAnimatorController; }
public MainPage() { InitializeComponent(); DataContext = new HudViewModel(this); Tweets = new ObservableCollection <Tweet>(); gestureDel = gestureHandler; gc = new GestureControl(gestureDel); //start gesture control gc.ConnectAndListen_Arduino(); }
public void TurnOff() { if (m_Target != null) { m_Target.rotation = m_OriginRotation; this.m_Target = null; this.m_Cam = null; } m_NoMarkerModeOn = false; m_CurGesture = GestureControl.NoTouch; }
public void TurnOn(Transform target, Camera cam, bool isDraggable, bool isScalable, bool isRotatable) { this.m_Target = target; m_OriginRotation = target.rotation; this.m_Cam = cam; this.m_IsDraggable = isDraggable; this.m_IsScalable = isScalable; this.m_IsRotatable = isRotatable; m_NoMarkerModeOn = true; m_CurGesture = GestureControl.NoTouch; }
public void TurnOn(Transform target, Camera cam, bool isOneFingerDraggable, bool isTwoFingerDraggable, bool isTwoFingerScalable, bool isTwoFingerRotatable) { StopAllCoroutines(); controlTarget = target; cameraTarget = cam; this.isOneFingerDraggable = isOneFingerDraggable; this.isTwoFingerDraggable = isTwoFingerDraggable; this.isTwoFingerScalable = isTwoFingerScalable; this.isTwoFingerRotatable = isTwoFingerRotatable; curGesture = GestureControl.NoTouch; }
// Use this for initialization void Start() { dataManager = GameObject.Find("gDataManager").GetComponent <DataManager> (); gestureManager = this.GetComponent <GestureControl> (); paintManager = this.GetComponent <PaintManager> (); palm = this.transform.GetChild(5).gameObject; grabHolder = this.transform.GetChild(5).GetChild(0).gameObject; thumbFinger = this.transform.GetChild(0).GetChild(2).gameObject; indexFinger = this.transform.GetChild(1).GetChild(2).gameObject; indexFingerPos = new Vector3[10]; thumbFingerPos = new Vector3[10]; pIndexFingerPos = Vector3.zero; pThumbFingerPos = Vector3.zero; _handThrowingPowerMultiplier = dataManager.handThrowingPowerMultiplier; context_buff = new int[context_buff_len]; context_dict.Add(0, "object"); context_dict.Add(1, "paint"); context_dict.Add(2, "menu"); context_dict.Add(3, "brush"); // Get menus if (GameObject.Find("FurnitureMenu") != null) { m_furnitureMenu = GameObject.Find("FurnitureMenu").GetComponent <VirtualFurnitureMenu>(); m_paintMenu = GameObject.Find("PaintMenu").GetComponent <VirtualPaintMenu>(); m_brushMenu = GameObject.Find("strokeMatMenu").GetComponent <VirtualMenuBrush>(); m_furnitureMenu.close(); m_paintMenu.close(); m_brushMenu.close(); } /*initial all user-defined settings*/ DataManager data_mngr = GameObject.Find("gDataManager").GetComponent <DataManager> (); palm_collider_delay = data_mngr.getPalmColliderDelay(); palm.GetComponent <Rigidbody> ().maxAngularVelocity = 0; //use for disable UI for photo //smallMenu = GameObject.Find("GameControlPanel"); //smallMenu.SetActive (false); // register new motion if (HandActionRecog.getInstance() != null && HandActionRecog.getInstance().BeginMotion("OpenMenu")) { HandActionRecog.getInstance().DefineTransform("palm|pinch|undefined", "palm|pinch|undefined", Vector3.up, -Vector3.up, 1.0f); HandActionRecog.getInstance().DefineTransform("palm|pinch|undefined", "palm|pinch|undefined", -Vector3.up, Vector3.up, 1.0f); HandActionRecog.getInstance().EndMotion(); } }
// Use this for initialization void Start() { //list of inks inkList = new List <LineRenderer> (); //list of highlights highlightSet = new Dictionary <LineRenderer, Material>(); //list of endpoints of lines & snap sphere endpoints_list = new List <Vector3>(); hsphere = Instantiate(highlightSphere); hsphere.SetActive(false); //paintPlane for is2d paintPlane = Instantiate(paintPlane_Prefab); paintPlane.SetActive(false); //liat of all materials if (materialPrototypes == null) { materialPrototypes = new List <Material>(); } //create basic line pattern if (basic_line == null) { basic_line = new GameObject("BasicLine"); basic_line.AddComponent <LineRenderer>(); basic_line.SetActive(false); } //curr width currWidth = 0; indexfinger_tip = this.transform.GetChild(1).GetChild(2).gameObject; //added thumb tip thumb_tip = this.transform.GetChild(0).GetChild(2).gameObject; palm = this.transform.GetChild(5).gameObject; //dwell m_dwell = new Dwell(); m_dwell.setScaleFactor(30f); if (m_PaintDwellBar != null) { //attach it to indexfinger (using its transform here) m_PaintDwellBar.BindToObject(this.transform.GetChild(1).GetChild(2)); } gestureManager = this.GetComponent <GestureControl> (); }
public void updateActiveObjects() { if (!ActiveHand) // if no hand { _activeIndex = null; _activeThumb = null; _activePalm = null; _activeGC = null; return; } _activeIndex = ActiveHand.transform.GetChild(1).GetChild(2).gameObject; _activeThumb = ActiveHand.transform.GetChild(0).GetChild(2).gameObject; _activePalm = ActiveHand.transform.GetChild(5).GetChild(0).gameObject; _activeGC = ActiveHand.GetComponent <GestureControl>(); }
/// <summary> /// Update member variable references to hands /// </summary> private void UpdateHandReference() { GameObject gobj = GameObject.Find("Hand_l"); if (gobj != null) { m_LeftHandMgr = gobj.GetComponent <HandManager>(); m_LeftHandGestureControl = gobj.GetComponent <GestureControl>(); } m_tLeftHand = gobj.transform.Find("palm"); gobj = GameObject.Find("Hand_r"); if (gobj != null) { m_RightHandMgr = gobj.GetComponent <HandManager>(); m_RightHandGestureControl = gobj.GetComponent <GestureControl>(); } m_tRightHand = gobj.transform.Find("palm"); }
// Use this for initialization void Start() { GameObject hHand = GameObject.Find("Hand_l"); if (hHand != null) { LeftHandGC = hHand.GetComponent <GestureControl> (); LeftHandPalm = hHand.transform.Find("palm"); Debug.Log("Hand Reg Lefthand found"); } hHand = GameObject.Find("Hand_r"); if (hHand != null) { RightHandGC = hHand.GetComponent <GestureControl> (); RightHandPalm = hHand.transform.Find("palm"); Debug.Log("Hand Reg Righthand found"); } leftHandList = new LinkedList <HandActionItem> (); rightHandList = new LinkedList <HandActionItem> (); handMotionList = new Dictionary <string, HandMotion> (); }
async void OnLoaded(object sender, RoutedEventArgs e) { _messageLabel.Text = GetTimeOfDayGreeting(); setUpMap(); // I want these to be serialized. foreach (var loader in new IAsyncLoader[] { _currentWeather, _forecastWeather, _eventCalendar, _eventCalendarLarge }.Where(loader => loader != null)) { await loader.LoadAsync(); } //setup gesture control variable fields gestureDel = gestureHandler; gc = new GestureControl(gestureDel); //start gesture control gc.ConnectAndListen_Arduino(); }
public void Start() { previousPosition = target.transform.position; gestureLibraryInput = gameObject.GetComponentInParent(typeof(GestureLibraryInput)) as GestureLibraryInput; gestureControl = gameObject.GetComponentInParent(typeof(GestureControl)) as GestureControl; }
void Update() { foreach (var touch in Input.touches) { if (touch.phase == TouchPhase.Began) { m_FingerRawPositionDict[touch.fingerId] = touch.position; } else if (touch.phase == TouchPhase.Ended) { m_FingerRawPositionDict.Remove(touch.fingerId); } } if (m_CurGesture == GestureControl.OutOfControl) { if (Input.touchCount == 0) { StopAllCoroutines(); m_CurGesture = GestureControl.NoTouch; } } else if (m_CurGesture == GestureControl.TwoMove || m_CurGesture == GestureControl.TwoRotate || m_CurGesture == GestureControl.TwoScale) { if (Input.touchCount != 2) { StopAllCoroutines(); m_CurGesture = GestureControl.OutOfControl; } } else if (m_CurGesture == GestureControl.TwoWait) { if (Input.touchCount != 2) { StopAllCoroutines(); m_CurGesture = GestureControl.OutOfControl; } else { Vector2 touch1Delta = Input.GetTouch(0).position - m_FingerRawPositionDict[Input.GetTouch(0).fingerId]; Vector2 touch2Delta = Input.GetTouch(1).position - m_FingerRawPositionDict[Input.GetTouch(1).fingerId]; if (touch1Delta.magnitude > Gesture_Enable_Distance_Threshold && touch2Delta.magnitude > Gesture_Enable_Distance_Threshold) { StopAllCoroutines(); if (Vector2.Dot(touch1Delta, touch2Delta) > 0) { Vector3 xMov; Vector3 yMov; GetRelativeTouch(touch1Delta + touch2Delta, out xMov, out yMov); if (xMov.sqrMagnitude > yMov.sqrMagnitude) { m_CurGesture = GestureControl.TwoRotate; if (m_IsRotatable) { if (m_NoMarkerModeOn) { StartCoroutine(OnTwoRotate()); } } } else { m_CurGesture = GestureControl.TwoMove; if (m_IsDraggable) { if (m_NoMarkerModeOn) { StartCoroutine(OnTwoMove()); } } } } else { m_CurGesture = GestureControl.TwoScale; if (m_IsScalable) { if (m_NoMarkerModeOn) { StartCoroutine(OnTwoScale()); } } } } } } else if (m_CurGesture == GestureControl.OneMove) { if (Input.touchCount == 2) { StopAllCoroutines(); m_CurGesture = GestureControl.TwoWait; } else if (Input.touchCount != 1) { StopAllCoroutines(); m_CurGesture = GestureControl.OutOfControl; } } else if (m_CurGesture == GestureControl.NoTouch) { if (Input.touchCount == 1) { m_CurGesture = GestureControl.OneMove; if (m_IsDraggable) { StopAllCoroutines(); if (m_NoMarkerModeOn) { StartCoroutine(OnOneMove()); } } } else if (Input.touchCount == 2) { m_CurGesture = GestureControl.TwoWait; StopAllCoroutines(); } } if (m_Target != null) { m_target_cam_vec = m_Cam.transform.position - m_Target.position; } }
public Vector3 GetGesturePosition(GestureControl.Hand hand) { // TODO return grabPosition; }
private void Update() { if (!controlTarget) { return; } foreach (var touch in Input.touches) { if (touch.phase == TouchPhase.Began) { originalPosition[touch.fingerId] = touch.position; } else if (touch.phase == TouchPhase.Ended) { originalPosition.Remove(touch.fingerId); } } if (curGesture == GestureControl.OutOfControl) { if (Input.touchCount == 0) { StopAllCoroutines(); curGesture = GestureControl.NoTouch; } } else if (curGesture == GestureControl.TwoMove || curGesture == GestureControl.TwoRotate || curGesture == GestureControl.TwoScale) { if (Input.touchCount != 2) { StopAllCoroutines(); curGesture = GestureControl.OutOfControl; } } else if (curGesture == GestureControl.TwoWait) { if (Input.touchCount != 2) { StopAllCoroutines(); curGesture = GestureControl.OutOfControl; } else { Vector2 touch1Delta = Input.GetTouch(0).position - originalPosition[Input.GetTouch(0).fingerId]; Vector2 touch2Delta = Input.GetTouch(1).position - originalPosition[Input.GetTouch(1).fingerId]; if (touch1Delta.magnitude > gestureEnableDistanceThreshold && touch2Delta.magnitude > gestureEnableDistanceThreshold) { StopAllCoroutines(); if (Vector2.Dot(touch1Delta, touch2Delta) > 0) { Vector3 xMov; Vector3 yMov; GetRelativeTouch(touch1Delta + touch2Delta, out xMov, out yMov); if (xMov.sqrMagnitude > yMov.sqrMagnitude) { curGesture = GestureControl.TwoRotate; if (isTwoFingerRotatable) { StartCoroutine(OnTwoRotate()); } } else { curGesture = GestureControl.TwoMove; if (isTwoFingerDraggable) { StartCoroutine(OnTwoMove()); } } } else { curGesture = GestureControl.TwoScale; if (isTwoFingerScalable) { StartCoroutine(OnTwoScale()); } } } } } else if (curGesture == GestureControl.OneMove) { if (Input.touchCount == 2) { StopAllCoroutines(); curGesture = GestureControl.TwoWait; } else if (Input.touchCount != 1) { StopAllCoroutines(); curGesture = GestureControl.OutOfControl; } } else if (curGesture == GestureControl.NoTouch) { if (Input.touchCount == 1) { curGesture = GestureControl.OneMove; if (isOneFingerDraggable) { StopAllCoroutines(); StartCoroutine(OnOneMove()); } } else if (Input.touchCount == 2) { curGesture = GestureControl.TwoWait; StopAllCoroutines(); } } if (controlTarget != null) { targetCamDistance = (cameraTarget.transform.position - controlTarget.position).magnitude; } }
void Awake() { gestureControl = gameObject.GetComponent(typeof(GestureControl)) as GestureControl; }
/// <summary> /// Consume a packet from the buffer if possible, then advance the buffer index. /// </summary> /// <param name="buffer">Byte buffer to decode</param> /// <param name="index">(Ref) Index to read into buffer</param> /// <exception cref="WearableProxyProtocolException">Thrown when a packet cannot be decoded and the buffer /// must be discarded.</exception> /// <exception cref="IndexOutOfRangeException">Thrown when a packet was partially consumed but ran out of /// buffer contents.</exception> public override void ProcessPacket(byte[] buffer, ref int index) { PacketTypeCode packetType = DecodePacketType(buffer, ref index); switch (packetType) { case PacketTypeCode.KeepAlive: { CheckFooter(buffer, ref index); if (KeepAlive != null) { KeepAlive.Invoke(); } break; } case PacketTypeCode.PingQuery: { CheckFooter(buffer, ref index); if (PingQuery != null) { PingQuery.Invoke(); } break; } case PacketTypeCode.PingResponse: { CheckFooter(buffer, ref index); if (PingResponse != null) { PingResponse.Invoke(); } break; } case PacketTypeCode.SensorControl: { bool enabled; SensorId sensor = DecodeSensorControl(buffer, ref index, out enabled); CheckFooter(buffer, ref index); if (SensorControl != null) { SensorControl.Invoke(sensor, enabled); } break; } case PacketTypeCode.SetRssiFilter: { int value = DecodeRSSIFilterControlPacket(buffer, ref index); CheckFooter(buffer, ref index); if (RSSIFilterValueChange != null) { RSSIFilterValueChange.Invoke(value); } break; } case PacketTypeCode.InitiateDeviceSearch: { CheckFooter(buffer, ref index); if (InitiateDeviceSearch != null) { InitiateDeviceSearch.Invoke(); } break; } case PacketTypeCode.StopDeviceSearch: { CheckFooter(buffer, ref index); if (StopDeviceSearch != null) { StopDeviceSearch.Invoke(); } break; } case PacketTypeCode.ConnectToDevice: { string uid = DecodeDeviceConnectPacket(buffer, ref index); CheckFooter(buffer, ref index); if (ConnectToDevice != null) { ConnectToDevice.Invoke(uid); } break; } case PacketTypeCode.DisconnectFromDevice: { CheckFooter(buffer, ref index); if (DisconnectFromDevice != null) { DisconnectFromDevice.Invoke(); } break; } case PacketTypeCode.QueryConnectionStatus: { CheckFooter(buffer, ref index); if (QueryConnectionStatus != null) { QueryConnectionStatus.Invoke(); } break; } case PacketTypeCode.QueryUpdateInterval: { CheckFooter(buffer, ref index); if (QueryUpdateInterval != null) { QueryUpdateInterval.Invoke(); } break; } case PacketTypeCode.SetUpdateInterval: { SensorUpdateInterval interval = DecodeSetUpdateIntervalPacket(buffer, ref index); CheckFooter(buffer, ref index); if (SetUpdateInterval != null) { SetUpdateInterval.Invoke(interval); } break; } case PacketTypeCode.QuerySensorStatus: { CheckFooter(buffer, ref index); if (QuerySensorStatus != null) { QuerySensorStatus.Invoke(); } break; } case PacketTypeCode.GestureControl: { bool enabled; GestureId gestureId = DecodeGestureControl(buffer, ref index, out enabled); CheckFooter(buffer, ref index); if (GestureControl != null) { GestureControl.Invoke(gestureId, enabled); } break; } case PacketTypeCode.QueryGestureStatus: { CheckFooter(buffer, ref index); if (QueryGestureStatus != null) { QueryGestureStatus.Invoke(); } break; } case PacketTypeCode.QueryRotationSource: { CheckFooter(buffer, ref index); if (QueryRotationSource != null) { QueryRotationSource.Invoke(); } break; } case PacketTypeCode.SetRotationSource: { RotationSensorSource source = DecodeRotationSource(buffer, ref index); CheckFooter(buffer, ref index); if (SetRotationSource != null) { SetRotationSource.Invoke(source); } break; } case PacketTypeCode.SensorFrame: case PacketTypeCode.DeviceList: case PacketTypeCode.ConnectionStatus: case PacketTypeCode.SensorStatus: case PacketTypeCode.UpdateIntervalValue: case PacketTypeCode.GestureStatus: case PacketTypeCode.RotationSourceValue: // Known, but contextually-invalid packet throw new WearableProxyProtocolException(WearableConstants.ProxyProviderInvalidPacketError); default: // Unknown or corrupt packet throw new WearableProxyProtocolException(WearableConstants.ProxyProviderInvalidPacketError); } }