private void ThreadLoop() { Y = m_HeadHeight; while (m_IsRunning) { if (m_RudderEnabled) { var errorCode = Sdk3dRudder.GetAxes(0, m_AxesParamDefault, m_AxesValue); if (errorCode == ErrorCode.Success) { X += m_AxesValue.Get(Axes.LeftRight) * m_MoveSpeed; Z -= m_AxesValue.Get(Axes.ForwardBackward) * m_MoveSpeed; if (m_SimulateCrouch) { var y = m_AxesValue.Get(Axes.UpDown); if (y < -0.5f) { Y = m_HeadHeight / 2; } else { Y = m_HeadHeight; } } #if DEBUG Console.WriteLine($"X: {X}, Y: {Y}, Z: {Z}"); #endif if (m_VridgeRemote.Head != null) { if (m_RotationEnabled) { Yaw += m_AxesValue.Get(Axes.Rotation) * m_RotationSpeed; m_VridgeRemote.Head.SetRotationAndPosition(Yaw, 0, 0, X, Y, Z); } else { m_VridgeRemote.Head.SetPosition(X, Y, Z); } } } } Thread.Sleep(10); } }
public void Start() { Stop(); var status = Sdk3dRudder.Init(); m_IsRunning = status != ErrorCode.Fail; if (m_IsRunning) { m_Thread = new Thread(new ThreadStart(ThreadLoop)); m_Thread.Start(); StatusLabel.Text = "Started"; } else { StatusLabel.Text = status.ToString(); } }