private static void DrawAnimations(ref ViewportOptions options) { if (animationNames.Length > 0) { ImGui.Text($"Animations: {animationNames.Length}"); if (ImGui.Combo(" ", ref currentSelectedAnimation, animationNames, animationNames.Length)) { if (currentSelectedAnimation >= 0 && currentSelectedAnimation < animationNames.Length) { options.AnimationUpdater = animationUpdaters[currentSelectedAnimation]; options.AnimationUpdater.Reset(); options.AnimationUpdater.RepeatMode = AnimationRepeatMode.Loop; options.PlayAnimation = true; } else { options.PlayAnimation = false; options.AnimationUpdater = null; } } } }
public static void DrawUI(int width, int height, ref ViewportOptions options, GroupNode rootNode) { ImGui.SetNextWindowPos(System.Numerics.Vector2.Zero); ImGui.SetNextWindowSize(new System.Numerics.Vector2(250, 350)); bool opened = true; ImGui.Begin("Model Loader Window", ref opened, ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse); if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("Load Model", !loading)) { if (ImGui.MenuItem("Open")) { LoadModel(rootNode, options.ShowEnvironmentMap); } ImGui.EndMenu(); } if (ImGui.BeginMenu("Options")) { ImGui.Checkbox("Dir Light Follow Camera", ref options.DirectionalLightFollowCamera); ImGui.SliderFloat("Dir Light Intensity", ref options.DirectionLightIntensity, 0, 1, "", ImGuiSliderFlags.AlwaysClamp); ImGui.SliderFloat("Ambient Light Intensity", ref options.AmbientLightIntensity, 0, 1, "", ImGuiSliderFlags.AlwaysClamp); ImGui.Separator(); ImGui.Checkbox("Show EnvironmentMap", ref options.ShowEnvironmentMap); ImGui.Checkbox("Enable SSAO", ref options.EnableSSAO); ImGui.Checkbox("Enable FXAA", ref options.EnableFXAA); ImGui.Checkbox("Enable Frustum", ref options.EnableFrustum); ImGui.Checkbox("Enable DpiScale", ref options.EnableDpiScale); if (ImGui.Checkbox("Show Wireframe", ref options.ShowWireframe)) { options.ShowWireframeChanged = true; } ImGui.Separator(); ImGui.ColorPicker3("Background Color", ref options.BackgroundColor); ImGui.EndMenu(); } if (!showImGuiDemo && ImGui.BeginMenu("ImGui Demo")) { if (ImGui.MenuItem("Show")) { showImGuiDemo = true; } ImGui.EndMenu(); } ImGui.EndMenuBar(); } if (ImGui.CollapsingHeader("Mouse Gestures", ImGuiTreeNodeFlags.DefaultOpen)) { ImGui.Text("Mouse Right: Rotate"); ImGui.Text("Mouse Middle: Pan"); ImGui.Separator(); if (!string.IsNullOrEmpty(SomeTextFromOutside)) { ImGui.Text(SomeTextFromOutside); } } ImGui.Separator(); ImGui.Text("FPS"); ImGui.PlotLines("", ref fps[0], fps.Length, 0, $"{fps[currFPSIndex]}", 30, 70, new System.Numerics.Vector2(200, 50)); ImGui.Text("Rendering Latency Ms"); ImGui.PlotLines("", ref latency[0], latency.Length, 0, $"{latency[currFPSIndex]}ms", 0, 5, new System.Numerics.Vector2(200, 50)); fps[currFPSIndex] = 1000f / (float)options.Viewport.RenderHost.RenderStatistics.LatencyStatistics.AverageValue; latency[currFPSIndex] = (float)options.Viewport.RenderHost.RenderStatistics.LatencyStatistics.AverageValue; frustumTest[currFPSIndex] = (float)options.Viewport.RenderHost.RenderStatistics.FrustumTestTime * 1000; ImGui.Text("Frustum Test Ms"); ImGui.PlotLines("", ref frustumTest[0], frustumTest.Length, 0, $"{frustumTest[currFPSIndex]}ms", 0, 5, new System.Numerics.Vector2(200, 50)); currFPSIndex = (currFPSIndex + 1) % frameDataLength; if (!loading && ImGui.CollapsingHeader("Scene Graph", ImGuiTreeNodeFlags.DefaultOpen)) { DrawSceneGraph(rootNode); } if (!loading && scene != null && scene.Animations != null) { DrawAnimations(ref options); } if (!loading && !string.IsNullOrEmpty(exception)) { ImGui.Separator(); ImGui.Text(exception); } if (loading) { ImGui.Text($"Loading: {modelName}"); var progress = ((float)(Stopwatch.GetTimestamp() - currentTime) / Stopwatch.Frequency) * 100 % 100; ImGui.ProgressBar(progress / 100, new System.Numerics.Vector2(width, 20), ""); } ImGui.End(); if (showImGuiDemo) { opened = false; ImGui.ShowDemoWindow(ref showImGuiDemo); } }