public override void UpdateComponent() { status = Status.Tracking; if (HydraDevice.status == Status.Unavailable) { status = Status.Unavailable; } if (HydraDevice.GetConfidence(isLeft) == 0) { status = Status.Present; } if (status == Status.Present || status == Status.Unavailable) { positionConfidence = 0; rotationConfidence = 0; gameObject.SetActive(false); return; } Vector3 localSensorPosition = Target.ToVector3(HydraDevice.GetControllerLocalPosition(isLeft)); Quaternion localSensorRotation = Target.ToQuaternion(HydraDevice.GetControllerLocalOrientation(isLeft)); transform.position = trackerTransform.TransformPoint(localSensorPosition); transform.rotation = trackerTransform.rotation * localSensorRotation; positionConfidence = HydraDevice.GetConfidence(isLeft); rotationConfidence = HydraDevice.GetConfidence(isLeft); gameObject.SetActive(true); UpdateInput(); }
public override void StartTracker(HumanoidControl _humanoid) { humanoid = _humanoid; if (!enabled) { return; } HydraDevice.Start(); AddTracker(humanoid, "Hydra BaseStation"); }
public override void UpdateTracker() { if (!enabled || trackerTransform == null) { return; } if (trackerTransform != null) { if (HydraDevice.status == Status.Unavailable) { trackerTransform.gameObject.SetActive(false); } else { trackerTransform.gameObject.SetActive(true); } } if (HydraDevice.status != Status.Unavailable) { if ((leftHandSensor.enabled && leftHandSensor.status == Status.Tracking) || (rightHandSensor.enabled && rightHandSensor.status == Status.Tracking)) { status = Status.Tracking; } else { status = Status.Present; } } else { status = Status.Unavailable; } deviceView.position = Target.ToVector(trackerTransform.position); deviceView.orientation = Target.ToRotation(trackerTransform.rotation); HydraDevice.Update(); }
private void UpdateInput() { HydraDevice.Controller hydraController = HydraDevice.GetController(isLeft); if (hydraController == null) { return; } float stickPress = hydraController.GetButton(HydraDevice.HydraButtons.JOYSTICK) ? 1 : 0; float joystickX = (Mathf.Abs(hydraController.m_JoystickX) < 0.1F) ? 0 : hydraController.m_JoystickX; float joystickY = (Mathf.Abs(hydraController.m_JoystickY) < 0.1F) ? 0 : hydraController.m_JoystickY; joystick = new Vector3(joystickX, joystickY, stickPress); bumper = hydraController.GetButton(HydraDevice.HydraButtons.BUMPER) ? 1 : 0; trigger = hydraController.m_Trigger; button1 = hydraController.GetButton(HydraDevice.HydraButtons.ONE) ? 1 : 0; button2 = hydraController.GetButton(HydraDevice.HydraButtons.TWO) ? 1 : 0; button3 = hydraController.GetButton(HydraDevice.HydraButtons.THREE) ? 1 : 0; button4 = hydraController.GetButton(HydraDevice.HydraButtons.FOUR) ? 1 : 0; option = hydraController.GetButton(HydraDevice.HydraButtons.START) ? 1 : 0; }