private void Sensors_ReadingAvailable(Sensors.Reading reading) { OrientationTracker.Primary.UpdateWithReading(reading); //OrientationTracker.Secondary.UpdateWithReading(reading, -1, true); // uncomment if using two IMUs if ((DateTime.Now - last).TotalMilliseconds > 30) { EulerAngles orientation = OrientationTracker.Primary.EstimateOrientation().GetEulerAngles(); int resolution = 1; int yaw = resolution * (int)Math.Round(orientation.Yaw * 180 / Math.PI / resolution); int pitch = resolution * (int)Math.Round(orientation.Pitch * 180 / Math.PI / resolution); int roll = resolution * (int)Math.Round(orientation.Roll * 180 / Math.PI / resolution); if (RemoveGravityCheckbox.Checked) { reading = OrientationTracker.SubtractGravity(reading); } Invoke(new MethodInvoker(delegate { StatusBox.Text = ""; StatusBox.Text += "ax = " + reading.Accelerometer1.X + " m/s^2" + Environment.NewLine; StatusBox.Text += "ay = " + reading.Accelerometer1.Y + " m/s^2" + Environment.NewLine; StatusBox.Text += "az = " + reading.Accelerometer1.Z + " m/s^2" + Environment.NewLine; StatusBox.Text += "gx = " + reading.Gyroscope1.X + " deg / s" + Environment.NewLine; StatusBox.Text += "gy = " + reading.Gyroscope1.Y + " deg / s" + Environment.NewLine; StatusBox.Text += "gz = " + reading.Gyroscope1.Z + " deg / s" + Environment.NewLine; StatusBox.Text += "mx = " + reading.Magnetometer1.X + " gauss" + Environment.NewLine; StatusBox.Text += "my = " + reading.Magnetometer1.Y + " gauss" + Environment.NewLine; StatusBox.Text += "mz = " + reading.Magnetometer1.Z + " gauss" + Environment.NewLine; StatusBox.Text += yaw + Environment.NewLine + pitch + Environment.NewLine + roll; })); last = DateTime.Now; } }
void Awake() { cam = _cam; gameBoard = _gameBoard; menu = _menu; gameInfo = _gameInfo; victoryScreen = _victoryScreen; boardGraphics = gameBoard.GetComponent <GraphicsHandler>(); boardOrientationTracker = gameBoard.GetComponent <OrientationTracker>(); gameInfo.SetActive(false); victoryScreen.SetActive(false); life = _life; maxLife = _life; }