예제 #1
0
        public void Draw()
        {
            if (windowOpen)
            {
                ImGui.Begin("Options", ref windowOpen, ImGuiWindowFlags.AlwaysAutoResize);
                ViewerControls.DropdownButton("Default Camera", ref config.DefaultCameraMode, camModesNormal);
                ImGui.SameLine();
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Default Camera");
                var pastC = cFilter;
                ImGui.Combo("Texture Filter", ref cFilter, filters, filters.Length);
                if (cFilter != pastC)
                {
                    SetTexFilter();
                    config.TextureFilter = cFilter;
                }
                ImGui.Combo("Antialiasing", ref cMsaa, msaaStrings, Math.Min(msaaLevels.Length, msaaStrings.Length));
                config.MSAA = msaaLevels[cMsaa];
                ImGui.Checkbox("View Buttons", ref config.ViewButtons);
                ImGui.Checkbox("Pause When Unfocused", ref config.PauseWhenUnfocused);
                if (ViewerControls.GradientButton("Viewport Background", config.Background, config.Background2, new Vector2(22), vps, config.BackgroundGradient))
                {
                    ImGui.OpenPopup("Viewport Background");
                    editCol  = new Vector3(config.Background.R, config.Background.G, config.Background.B);
                    editCol2 = new Vector3(config.Background2.R, config.Background2.G, config.Background2.B);
                    editGrad = config.BackgroundGradient;
                }
                ImGui.SameLine();
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Viewport Background");
                bool wOpen = true;
                if (ImGui.BeginPopupModal("Viewport Background", ref wOpen, ImGuiWindowFlags.AlwaysAutoResize))
                {
                    ImGui.Checkbox("Gradient", ref editGrad);

                    ImGui.ColorPicker3(editGrad ? "Top###a" : "###a", ref editCol);
                    if (editGrad)
                    {
                        ImGui.SameLine();
                        ImGui.ColorPicker3("Bottom###b", ref editCol2);
                    }
                    if (ImGui.Button("OK"))
                    {
                        config.Background         = new Color4(editCol.X, editCol.Y, editCol.Z, 1);
                        config.Background2        = new Color4(editCol2.X, editCol2.Y, editCol2.Z, 1);
                        config.BackgroundGradient = editGrad;
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.SameLine();
                    if (ImGui.Button("Default"))
                    {
                        var def = Color4.CornflowerBlue * new Color4(0.3f, 0.3f, 0.3f, 1f);
                        editCol  = new Vector3(def.R, def.G, def.B);
                        editGrad = false;
                    }
                    ImGui.SameLine();
                    if (ImGui.Button("Cancel"))
                    {
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.EndPopup();
                }
                if (ImGui.ColorButton("Grid Color", config.GridColor, ImGuiColorEditFlags.NoAlpha, new Vector2(22)))
                {
                    ImGui.OpenPopup("Grid Color");
                    editCol = new Vector3(config.GridColor.R, config.GridColor.G, config.GridColor.B);
                }
                ImGui.SameLine();
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Grid Color");
                if (ImGui.BeginPopupModal("Grid Color", ref wOpen, ImGuiWindowFlags.AlwaysAutoResize))
                {
                    ImGui.ColorPicker3("###a", ref editCol);
                    if (ImGui.Button("OK"))
                    {
                        config.GridColor = new Color4(editCol.X, editCol.Y, editCol.Z, 1);
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.SameLine();
                    if (ImGui.Button("Default"))
                    {
                        var def = Color4.CornflowerBlue;
                        editCol  = new Vector3(def.R, def.G, def.B);
                        editGrad = false;
                    }
                    ImGui.EndPopup();
                }
                guiHelper.PauseWhenUnfocused = config.PauseWhenUnfocused;
                ImGui.End();
            }
        }
예제 #2
0
        public override void Draw()
        {
            bool doTabs = false;

            popups.Run();
            HardpointEditor();
            PartEditor();
            foreach (var t in openTabs)
            {
                if (t)
                {
                    doTabs = true; break;
                }
            }
            var contentw = ImGui.GetWindowContentRegionWidth();

            if (doTabs)
            {
                ImGui.Columns(2, "##panels", true);
                if (firstTab)
                {
                    ImGui.SetColumnWidth(0, contentw * 0.23f);
                    firstTab = false;
                }
                ImGui.BeginChild("##tabchild");
                if (openTabs[0])
                {
                    HierarchyPanel();
                }
                if (openTabs[1])
                {
                    AnimationPanel();
                }
                if (openTabs[2])
                {
                    SkeletonPanel();
                }
                if (openTabs[3])
                {
                    RenderPanel();
                }
                ImGui.EndChild();
                ImGui.NextColumn();
            }
            TabButtons();
            ImGui.BeginChild("##main");
            ViewerControls.DropdownButton("View Mode", ref viewMode, viewModes);
            ImGui.SameLine();
            ImGui.Checkbox("Background", ref doBackground);
            ImGui.SameLine();
            if (!(drawable is SphFile)) //Grid too small for planets lol
            {
                ImGui.Checkbox("Grid", ref showGrid);
                ImGui.SameLine();
            }
            if (hasVWire)
            {
                ImGui.Checkbox("VMeshWire", ref drawVMeshWire);
                ImGui.SameLine();
            }
            ImGui.Checkbox("Wireframe", ref doWireframe);
            DoViewport();
            //
            var camModes = (cameraPart != null) ? camModesCockpit : camModesNormal;

            ViewerControls.DropdownButton("Camera Mode", ref selectedCam, camModes);
            modelViewport.Mode = (CameraModes)(camModes[selectedCam].Tag);
            ImGui.SameLine();
            if (ImGui.Button("Reset Camera (Ctrl+R)"))
            {
                ResetCamera();
            }
            ImGui.SameLine();
            //
            if (!(drawable is SphFile) && !(drawable is DF.DfmFile))
            {
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Level of Detail:");
                ImGui.SameLine();
                ImGui.Checkbox("Use Distance", ref useDistance);
                ImGui.SameLine();
                ImGui.PushItemWidth(-1);
                if (useDistance)
                {
                    ImGui.SliderFloat("Distance", ref levelDistance, 0, maxDistance, "%f", 1);
                }
                else
                {
                    ImGui.Combo("Level", ref level, levels, levels.Length);
                }
                ImGui.PopItemWidth();
            }
            ImGui.EndChild();

            if (_window.Config.ViewButtons)
            {
                ImGui.SetNextWindowPos(new Vector2(_window.Width - viewButtonsWidth, 90));
                ImGui.Begin("viewButtons#" + Unique, ImGuiWindowFlags.AlwaysAutoResize |
                            ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoMove);
                ImGui.Dummy(new Vector2(120, 2));
                ImGui.Columns(2, "##border", false);
                if (ImGui.Button("Top", new Vector2(55, 0)))
                {
                    modelViewport.GoTop();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Bottom", new Vector2(55, 0)))
                {
                    modelViewport.GoBottom();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Left", new Vector2(55, 0)))
                {
                    modelViewport.GoLeft();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Right", new Vector2(55, 0)))
                {
                    modelViewport.GoRight();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Front", new Vector2(55, 0)))
                {
                    modelViewport.GoFront();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Back", new Vector2(55, -1)))
                {
                    modelViewport.GoBack();
                }
                viewButtonsWidth = ImGui.GetWindowWidth() + 60;
                ImGui.End();
            }
        }
예제 #3
0
        public override void Draw()
        {
            ImGui.Columns(2);
            ImGui.BeginChild("##munitions");
            foreach (var m in projectileList)
            {
                if (ImGui.Selectable(m.Nickname, currentMunition == m))
                {
                    currentMunition = m;
                    constEffect     = effects.FindEffect(m.ConstEffect);
                    bolt            = effects.BeamBolts.FirstOrDefault(x =>
                                                                       x.Nickname.Equals(constEffect.VisBeam, StringComparison.OrdinalIgnoreCase));
                    beam = effects.BeamSpears.FirstOrDefault(x =>
                                                             x.Nickname.Equals(constEffect.VisBeam, StringComparison.OrdinalIgnoreCase));
                    viewport.ResetControls();
                }
            }
            ImGui.EndChild();
            ImGui.NextColumn();
            ImGui.BeginChild("##rendering");
            ViewerControls.DropdownButton("Camera Mode", ref cameraMode, camModes);
            viewport.Mode = (CameraModes)camModes[cameraMode].Tag;
            ImGui.SameLine();
            if (ImGui.Button("Reset Camera (Ctrl+R)"))
            {
                viewport.ResetControls();
            }
            viewport.Begin();
            Matrix4x4 rot = Matrix4x4.CreateRotationX(viewport.CameraRotation.Y) *
                            Matrix4x4.CreateRotationY(viewport.CameraRotation.X);
            var dirRot = Matrix4x4.CreateRotationX(viewport.ModelRotation.Y) * Matrix4x4.CreateRotationY(viewport.ModelRotation.X);
            var norm   = Vector3.TransformNormal(-Vector3.UnitZ, dirRot);
            var dir    = Vector3.Transform(-Vector3.UnitZ, rot);
            var to     = viewport.CameraOffset + (dir * 10);

            if (viewport.Mode == CameraModes.Arcball)
            {
                to = Vector3.Zero;
            }
            camera.Update(viewport.RenderWidth, viewport.RenderHeight, viewport.CameraOffset, to, rot);
            mw.Commands.StartFrame(mw.RenderState);
            beams.Begin(mw.Commands, mw.Resources, camera);
            var position = Vector3.Zero;

            if (beam != null)
            {
                beams.AddBeamSpear(position, norm, beam);
            }
            else if (bolt != null)
            {
                Vector2 tl, tr, bl, br;
                //CoordsFromTexture(bolt.HeadTexture, out tl, out tr, out bl, out br);
            }
            beams.End();
            fxPool.Draw(camera, null, mw.Resources, null);
            mw.Commands.DrawOpaque(mw.RenderState);
            mw.RenderState.DepthWrite = false;
            mw.Commands.DrawTransparent(mw.RenderState);
            mw.RenderState.DepthWrite = true;
            if (constEffect != null)
            {
                mw.Renderer2D.Start(viewport.RenderWidth, viewport.RenderHeight);
                var debugText = new StringBuilder();
                debugText.AppendLine($"ConstEffect: {constEffect.Nickname}");
                if (bolt != null)
                {
                    debugText.AppendLine($"Bolt: {bolt.Nickname}");
                }
                if (beam != null)
                {
                    debugText.AppendLine($"Beam: {beam.Nickname}");
                }
                mw.Renderer2D.DrawString("Arial", 10, debugText.ToString(), Vector2.One, Color4.White);
                mw.Renderer2D.Finish();
            }
            viewport.End();
            ImGui.EndChild();
        }
예제 #4
0
        public override void Draw()
        {
            bool doTabs = false;

            foreach (var t in openTabs)
            {
                if (t)
                {
                    doTabs = true; break;
                }
            }
            var contentw = ImGui.GetWindowContentRegionWidth();

            if (doTabs)
            {
                ImGui.Columns(2, "##alecolumns", true);
                ImGui.BeginChild("##leftpanel");
                if (openTabs[0])
                {
                    NodePanel();
                }
                ImGui.EndChild();
                ImGui.NextColumn();
            }
            TabButtons();
            ImGui.SameLine();
            ImGui.BeginChild("##renderpanel");
            //Fx management
            lastEffect = currentEffect;
            ImGui.Text("Effect:");
            ImGui.SameLine();
            ImGui.Combo("##effect", ref currentEffect, effectNames, effectNames.Length);
            if (currentEffect != lastEffect)
            {
                SetupRender(currentEffect);
            }
            ImGui.SameLine();
            ImGui.Button("+");
            ImGui.SameLine();
            ImGui.Button("-");
            ImGui.Separator();
            //Viewport
            ImGui.BeginChild("##renderchild");
            //Generate render target
            aleViewport.Begin();
            DrawGL(aleViewport.RenderWidth, aleViewport.RenderHeight);
            //Display + Camera controls
            aleViewport.End();
            //Action Bar
            ViewerControls.DropdownButton("Camera Mode", ref cameraMode, camModes);
            aleViewport.Mode = (CameraModes)camModes[cameraMode].Tag;
            ImGui.SameLine();
            if (ImGui.Button("Reset Camera (Ctrl+R)"))
            {
                aleViewport.ResetControls();
            }
            ImGui.SameLine();
            if (ImGui.Button("Reset Fx"))
            {
                instance.Reset();
            }
            ImGui.SameLine();
            ImGui.Text(string.Format("T: {0:0.000}", instance.GlobalTime));
            ImGui.EndChild();
            ImGui.EndChild();
        }