public override void Hover_Start(DHUI_HoverEventArgs _hoverEvent) { base.Hover_Start(_hoverEvent); DHUI_FlightCommand_MoveTo cmd = new DHUI_FlightCommand_MoveTo(m_center.position, m_center.rotation, _droneSpeed); m_interactionManager.FlightController.AddToFrontOfQueue(cmd, true, true); }
private void NextTarget() { if (!back) { WriteFile("Test5_Target" + target + "_To.txt"); back = true; _target = _baseTransform; DHUI_FlightCommand_MoveTo cmd = new DHUI_FlightCommand_MoveTo(_baseTransform.position, _baseTransform.rotation, 0.2f); _flightControl.AddToFrontOfQueue(cmd, true, true); } else { WriteFile("Test5_Target" + target + "_Back.txt"); back = false; target++; if (target >= _transforms.Count) { Debug.Log("Done Recording"); record = false; return; } _target = _transforms[target]; DHUI_FlightCommand_MoveTo cmd = new DHUI_FlightCommand_MoveTo(_transforms[target].position, _transforms[target].rotation, 0.2f); _flightControl.AddToFrontOfQueue(cmd, true, true); } errors = new List <float>(); errorsRetargeted = new List <float>(); errorsRot = new List <float>(); counter = 0; }
public override void Hover_Start(DHUI_HoverEventArgs _hand) { DHUI_FlightCommand_MoveTo cmd = new DHUI_FlightCommand_MoveTo(m_centerPoint.position, m_centerPoint.rotation); m_interactionManager.FlightController.AddToFrontOfQueue(cmd, true, true); SetDebugText(0, buttonMode); SetDebugText(5, _activationDistance.ToString()); }
protected void UpdateDronePosition(float _speed = 0.5f) { if (m_droneTargetPoint == null) { return; } DHUI_FlightCommand_MoveTo cmd = new DHUI_FlightCommand_MoveTo(m_droneTargetPoint.position, m_droneTargetPoint.rotation, _speed); m_interactionManager.FlightController.AddToFrontOfQueue(cmd, true, true); }
protected void SentDroneToInitialPosition() { if (m_droneTargetPoint == null) { m_droneTargetPoint = new GameObject("DroneTargetPoint").transform; m_droneTargetPoint.transform.parent = transform; m_droneTargetPoint.transform.position = m_centerPoint.position; m_droneTargetPoint.transform.rotation = m_centerPoint.rotation; } DHUI_FlightCommand_MoveTo cmd = new DHUI_FlightCommand_MoveTo(m_droneTargetPoint.position, m_droneTargetPoint.rotation, _initialPositioningDroneSpeed); m_interactionManager.FlightController.AddToFrontOfQueue(cmd, true, true); }
public override void Hover_Stay(DHUI_HoverEventArgs _hoverEvent) { base.Hover_Stay(_hoverEvent); if (_invertActivation) { SwitchState = m_movingPart.transform.localRotation.y > _activationThreshold; } else { SwitchState = m_movingPart.transform.localRotation.y < _activationThreshold; } DHUI_FlightCommand_MoveTo cmd = new DHUI_FlightCommand_MoveTo(m_center.position, m_center.rotation, _droneSpeed); m_interactionManager.FlightController.AddToFrontOfQueue(cmd, true, true); if (SwitchState) { Activation_Stay(); } }
protected void FixedUpdate() { if (record) { errors.Add(Vector3.Distance(_target.position, _drone.position)); errorsRetargeted.Add(GetHapticRetargetingDist()); errorsRot.Add(Quaternion.Angle(_target.rotation, _drone.rotation)); Debug.Log(Vector3.Distance(coll.ClosestPoint(_target.position), _target.position)); if (counter == maxCounter) { NextTarget(); return; } counter++; } if (Input.GetKeyDown(KeyCode.A)) { if (record) { } else { Debug.Log("Start"); errors = new List <float>(); errorsRetargeted = new List <float>(); errorsRot = new List <float>(); record = true; counter = 0; _target = _transforms[0]; DHUI_FlightCommand_MoveTo cmd = new DHUI_FlightCommand_MoveTo(_transforms[0].position, _transforms[0].rotation, 0.2f); _flightControl.AddToFrontOfQueue(cmd, true, true); } } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.UpArrow)) { DHUI_FlightCommand_MoveTo cmd = new DHUI_FlightCommand_MoveTo(transform.position, transform.rotation, 0.2f); controller.AddToFrontOfQueue(cmd, true, true); } if (Input.GetKeyDown(KeyCode.RightArrow)) { DHUI_FlightCommand_WaitForDrone cmd = new DHUI_FlightCommand_WaitForDrone(); cmd.waitingTimeout = 20; controller.AddToFrontOfQueue(cmd, true, true); } if (Input.GetKeyDown(KeyCode.LeftArrow)) { DHUI_FlightCommand_LandAtStart cmd = new DHUI_FlightCommand_LandAtStart(); controller.AddToFrontOfQueue(cmd, true, true); } if (Input.GetKeyDown(KeyCode.DownArrow)) { DHUI_FlightCommand_LandHere cmd = new DHUI_FlightCommand_LandHere(); controller.AddToFrontOfQueue(cmd, true, true); } }
protected virtual void UpdateFlightController() { DHUI_FlightCommand_MoveTo cmd = new DHUI_FlightCommand_MoveTo(m_droneTargetPoint.position, m_droneTargetPoint.rotation, _droneSpeed); m_interactionManager.FlightController.AddToFrontOfQueue(cmd, true, true); }
public override void Hover_Stay(DHUI_HoverEventArgs _hand) { if (m_debugCanvas != null) { m_debugCanvas.SetActive(true); } float dist = Mathf.Abs(_hand.InteractorPosition.z - CenterPoint.z); SetDebugText(2, dist.ToString()); if (mode == ModeTesting.Activated || mode == ModeTesting.Released) { SetMode(ModeTesting.Released); } else if (Vector3.Angle(_hand.InteractorPosition - CenterPoint, m_centerPoint.forward) > 90) { if (dist < 0.01f) { SetMode(ModeTesting.Touched); } else { SetMode(ModeTesting.Hovered); } m_hoverInformationObject.gameObject.SetActive(true); } else { SetMode(ModeTesting.Pressed); m_hoverInformationObject.gameObject.SetActive(false); } float x = _hand.InteractorPosition.x; float y = _hand.InteractorPosition.y; float minX = CenterPoint.x - transform.localScale.x * 0.5f; float maxX = CenterPoint.x + transform.localScale.x * 0.5f; float minY = CenterPoint.y - transform.localScale.y * 0.5f; float maxY = CenterPoint.y + transform.localScale.y * 0.5f; if (x < minX) { x = minX; } if (x > maxX) { x = maxX; } if (y < minY) { y = minY; } if (y > maxY) { y = maxY; } float z = CenterPoint.z; m_hoverInformationObject.position = new Vector3(x, y, z); SetDebugText(3, "X: " + ((x - CenterPoint.x) / (transform.localScale.x / 2)).ToString("F2") + " Y: " + ((y - CenterPoint.y) / (transform.localScale.y / 2)).ToString("F2")); DHUI_FlightCommand_MoveTo cmd = new DHUI_FlightCommand_MoveTo(m_hoverInformationObject.position, m_hoverInformationObject.rotation); m_interactionManager.FlightController.AddToFrontOfQueue(cmd, true, true); if (m_hoverDistanceInformationObject != null) { if (dist > 0.2f) { dist = 0.2f; } m_hoverDistanceInformationObject.localScale = new Vector3(dist * 15, dist * 15, 1); } if (m_movingPart != null && m_staticPart != null && _activationDistance > 0) { float pressDist = Vector3.Distance(m_pressedDistanceMovingObject.position, m_pressedDistanceStaticObject.position); SetDebugText(4, pressDist.ToString("F2")); if (pressDist > _activationDistance) { SetMode(ModeTesting.Activated); OnActivated?.Invoke(); } } }