void GetAxis() { // Get state of Controller with port number : 0 rudder = s3DRudderManager.Instance.GetRudder(IndexRudder); if (UseCurve) { axis = rudder.GetAxisWithCurve(ModeAxis, curves); } else { axis = rudder.GetAxis(ModeAxis); } // Get the direction of Controller and multiply by deltatime and speed if (CanMove) { if (Move3D) { translation = Vector3.Scale(rudder.GetAxis3D(axis), SpeedTranslation * Time.deltaTime); } else { translation.x = axis.GetXAxis() * SpeedTranslation.x * Time.deltaTime; translation.z = axis.GetYAxis() * SpeedTranslation.z * Time.deltaTime; } } if (CanRotate) { rotation *= Quaternion.AngleAxis(axis.GetZRotation() * SpeedRotation * Time.deltaTime, Vector3.up); } }
void DisplayRudder(int i) { rudder = s3DRudderManager.Instance.GetRudder(i); ns3DRudder.Status status = rudder.GetStatus(); string info = status == ns3DRudder.Status.NoStatus ? "Not Connected" : "Connected FW : " + rudder.GetVersion().ToString("X4"); show[i] = EditorGUILayout.Foldout(show[i], "3dRudder " + i + " (" + info + ")"); if (show[i]) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.LabelField("Axis", EditorStyles.boldLabel); ns3DRudder.Axis axis = rudder.GetAxis(); EditorGUILayout.Slider("Roll (X)", ParsePrecision(axis.GetXAxis()), sliderAxes.x, sliderAxes.y); EditorGUILayout.Slider("Pitch (Y)", ParsePrecision(axis.GetYAxis()), sliderAxes.x, sliderAxes.y); EditorGUILayout.Slider("Up/Down (Z)", ParsePrecision(axis.GetZAxis()), sliderAxes.x, sliderAxes.y); EditorGUILayout.Slider("Yaw (Z rotation)", ParsePrecision(axis.GetZRotation()), sliderAxes.x, sliderAxes.y); EditorGUILayout.Space(); EditorGUILayout.LabelField("Info", EditorStyles.boldLabel); var style = new GUIStyle(GUI.skin.label); style.normal.textColor = status > ns3DRudder.Status.StayStill ? new Color(0, 0.75f, 0) : new Color(0.75f, 0, 0); EditorGUILayout.BeginHorizontal(); float labelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 40; EditorGUILayout.LabelField("Status", status.ToString(), style); if (GUILayout.Button("Test sound")) { rudder.PlaySnd(4400, 100); } if (GUILayout.Button(rudder.IsFrozen() ? "Unfreeze" : "Freeze")) { rudder.SetFreeze(!rudder.IsFrozen()); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); GUILayout.Label("Sensors", EditorStyles.boldLabel); DisplaySensor(rudder); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUIUtility.labelWidth = labelWidth; } }
/// <summary> /// Update cursor position on canvas based on footpedal axis input. /// Since the experiment is 2D, it only requires two axes from the pedal so this control method is mechanically identical to the xbox joystick method. /// </summary> private void TrackFootpedal() { Axis = Rudder.GetAxis(_modeAxis); _gazeCursor.SetPositionFromJoystick(-Axis.GetXAxis(), -Axis.GetYAxis()); }