/// <inheritdoc /> protected override void OnRender() { ImGui.SetNextWindowPos(new Vector2(10.0f, 100.0f)); ImGui.SetNextWindowSize(new Vector2(200.0f, 700.0f)); ImGui.Begin("Tuning", ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize); ImGui.Separator(); ImGui.PushItemWidth(ImGui.GetWindowWidth() * 0.5f); const ImGuiComboFlags comboFlags = 0; string[] bendModels = { "Spring", "PBD Ang", "XPBD Ang", "PBD Dist", "PBD Height" }; string[] stretchModels = { "PBD", "XPBD" }; ImGui.Text("Rope 1"); var bendModel1 = (int)_tuning1.BendingModel; if (ImGui.BeginCombo("Bend Model##1", bendModels[bendModel1], comboFlags)) { for (var i = 0; i < bendModels.Length; ++i) { var isSelected = bendModel1 == i; if (ImGui.Selectable(bendModels[i], isSelected)) { bendModel1 = i; _tuning1.BendingModel = (BendingModel)i; } if (isSelected) { ImGui.SetItemDefaultFocus(); } } ImGui.EndCombo(); } ImGui.SliderFloat("Damping##B1", ref _tuning1.BendDamping, 0.0f, 4.0f, "%.1f"); ImGui.SliderFloat("Hertz##B1", ref _tuning1.BendHertz, 0.0f, 60.0f, "%.0f"); ImGui.SliderFloat("Stiffness##B1", ref _tuning1.BendStiffness, 0.0f, 1.0f, "%.1f"); ImGui.Checkbox("Isometric##1", ref _tuning1.Isometric); ImGui.Checkbox("Fixed Mass##1", ref _tuning1.FixedEffectiveMass); ImGui.Checkbox("Warm Start##1", ref _tuning1.WarmStart); var stretchModel1 = (int)_tuning1.StretchingModel; if (ImGui.BeginCombo("Stretch Model##1", stretchModels[stretchModel1], comboFlags)) { for (var i = 0; i < stretchModels.Length; ++i) { var isSelected = stretchModel1 == i; if (ImGui.Selectable(stretchModels[i], isSelected)) { stretchModel1 = i; _tuning1.StretchingModel = (StretchingModel)i; } if (isSelected) { ImGui.SetItemDefaultFocus(); } } ImGui.EndCombo(); } ImGui.SliderFloat("Damping##S1", ref _tuning1.StretchDamping, 0.0f, 4.0f, "%.1f"); ImGui.SliderFloat("Hertz##S1", ref _tuning1.StretchHertz, 0.0f, 60.0f, "%.0f"); ImGui.SliderFloat("Stiffness##S1", ref _tuning1.StretchStiffness, 0.0f, 1.0f, "%.1f"); ImGui.SliderInt("Iterations##1", ref _iterations1, 1, 100, "%d"); ImGui.Separator(); ImGui.Text("Rope 2"); var bendModel2 = (int)_tuning2.BendingModel; if (ImGui.BeginCombo("Bend Model##2", bendModels[bendModel2], comboFlags)) { for (var i = 0; i < bendModels.Length; ++i) { var isSelected = bendModel2 == i; if (ImGui.Selectable(bendModels[i], isSelected)) { bendModel2 = i; _tuning2.BendingModel = (BendingModel)i; } if (isSelected) { ImGui.SetItemDefaultFocus(); } } ImGui.EndCombo(); } ImGui.SliderFloat("Damping##", ref _tuning2.BendDamping, 0.0f, 4.0f, "%.1f"); ImGui.SliderFloat("Hertz##", ref _tuning2.BendHertz, 0.0f, 60.0f, "%.0f"); ImGui.SliderFloat("Stiffness##", ref _tuning2.BendStiffness, 0.0f, 1.0f, "%.1f"); ImGui.Checkbox("Isometric##2", ref _tuning2.Isometric); ImGui.Checkbox("Fixed Mass##2", ref _tuning2.FixedEffectiveMass); ImGui.Checkbox("Warm Start##2", ref _tuning2.WarmStart); var stretchModel2 = (int)_tuning2.StretchingModel; if (ImGui.BeginCombo("Stretch Model##2", stretchModels[stretchModel2], comboFlags)) { for (var i = 0; i < stretchModels.Length; ++i) { var isSelected = stretchModel2 == i; if (ImGui.Selectable(stretchModels[i], isSelected)) { stretchModel2 = i; _tuning2.StretchingModel = (StretchingModel)i; } if (isSelected) { ImGui.SetItemDefaultFocus(); } } ImGui.EndCombo(); } ImGui.SliderFloat("Damping##S2", ref _tuning2.StretchDamping, 0.0f, 4.0f, "%.1f"); ImGui.SliderFloat("Hertz##S2", ref _tuning2.StretchHertz, 0.0f, 60.0f, "%.0f"); ImGui.SliderFloat("Stiffness##S2", ref _tuning2.StretchStiffness, 0.0f, 1.0f, "%.1f"); ImGui.SliderInt("Iterations##2", ref _iterations2, 1, 100, "%d"); ImGui.Separator(); ImGui.SliderFloat("Speed", ref _speed, 10.0f, 100.0f, "%.0f"); if (ImGui.Button("Reset")) { _position1.Set(-5.0f, 15.0f); _position2.Set(5.0f, 15.0f); _rope1.Reset(_position1); _rope2.Reset(_position2); } ImGui.PopItemWidth(); ImGui.End(); _rope1.Draw(Drawer); _rope2.Draw(Drawer); DrawString("Press comma and period to move left and right"); }