static void ReloadMaterial(FMAT mat)
 {
     mat.UpdateRenderState();
     foreach (FSHP mesh in mat.GetMappedMeshes())
     {
         mesh.ReloadShader();
     }
 }
        static void ReloadMaterial(FMAT mat)
        {
            mat.Material.RenderState.PolygonControl.CullBack  = mat.CullBack;
            mat.Material.RenderState.PolygonControl.CullFront = mat.CullFront;

            mat.UpdateRenderState();
            foreach (FSHP mesh in mat.GetMappedMeshes())
            {
                mesh.ReloadShader();
            }
        }
        public static void Render(FMAT material)
        {
            RenderHeader();

            if (ImGui.BeginChild("RENDER_INFO_LIST"))
            {
                int index = 0;
                foreach (var renderInfo in material.Material.RenderInfos.Values)
                {
                    ImGui.Columns(2);
                    if (ImGui.Selectable(renderInfo.Name, SelectedIndices.Contains(index)))
                    {
                        SelectedIndices.Clear();
                        SelectedIndices.Add(index);
                    }
                    ImGui.NextColumn();
                    ImGui.Text(GetDataString(renderInfo, ","));
                    ImGui.NextColumn();

                    if (dialogOpen && SelectedIndices.Contains(index))
                    {
                        ActiveDialog.LoadDialog(renderInfo, dialogOpen, (o, e) =>
                        {
                            material.UpdateRenderState();
                            foreach (FSHP mesh in material.GetMappedMeshes())
                            {
                                mesh.ReloadShader();
                            }
                        });
                    }

                    if (SelectedIndices.Contains(index) && ImGui.IsMouseDoubleClicked(0))
                    {
                        dialogOpen = true;
                        ActiveDialog.OnLoad(material, renderInfo);
                        ImGui.OpenPopup("##render_info_dialog");
                    }

                    index++;

                    ImGui.Columns(1);
                }
            }
            ImGui.EndChild();
        }
        static void SelectSampler(FMAT material, UVViewport UVViewport, int index, bool onLoad)
        {
            var materialData = material.Material;

            var sampler   = materialData.Samplers[index].TexSampler;
            var texMapSel = materialData.TextureRefs[index];

            //Texture map info
            if (ImGui.CollapsingHeader("Texture Info", ImGuiTreeNodeFlags.DefaultOpen))
            {
                ImGuiHelper.InputFromText("Name", texMapSel, "Name", 200);
            }

            var width = ImGui.GetWindowWidth();

            //A UV preview window drawn using opengl
            if (ImGui.CollapsingHeader("Preview", ImGuiTreeNodeFlags.DefaultOpen))
            {
                if (ImGui.BeginChild("uv_viewport1", new Vector2(width, 150)))
                {
                    if (onLoad)
                    {
                        var meshes = material.GetMappedMeshes();

                        UVViewport.ActiveObjects.Clear();
                        foreach (FSHP mesh in meshes)
                        {
                            UVViewport.ActiveObjects.Add(mesh);
                        }
                    }

                    UVViewport.ActiveTextureMap = material.TextureMaps[index];
                    UVViewport.Render((int)width, 150);
                }
                ImGui.EndChild();
            }

            if (ImGui.BeginChild("sampler_properties"))
            {
                LoadProperties(sampler);
                material.ReloadTextureMap(index);
                ImGui.EndChild();
            }
        }
Exemple #5
0
        public static void Render(FMAT material)
        {
            if (LoadedOptions.Count == 0)
            {
                foreach (var op in material.ShaderOptions)
                {
                    LoadedOptions.Add(op.Key, op.Value);
                }
            }

            bool isValid = true;

            var meshes = material.GetMappedMeshes();

            foreach (FSHP mesh in meshes)
            {
                if (!mesh.HasValidShader)
                {
                    isValid = false;
                }
            }

            if (!isValid)
            {
                ImGui.TextColored(new System.Numerics.Vector4(1f, 0, 0.0f, 1), "Invalid Option Combination!");
            }
            else
            {
                ImGui.Text("");
            }

            //ImGui.TextColored(new System.Numerics.Vector4(0.2f, 1, 0.3f, 1), "Valid Option Combination!");

            RenderHeader(material);

            if (ImGui.BeginChild("OPTION_LIST"))
            {
                ImGui.Columns(2);

                int index = 0;
                foreach (var option in LoadedOptions)
                {
                    if (SelectedIndices.Contains(index))
                    {
                        if (ImGui.CollapsingHeader(option.Key, ImGuiTreeNodeFlags.DefaultOpen))
                        {
                            string value = option.Value;
                            if (ImGui.InputText("", ref value, 100))
                            {
                                material.ShaderOptions[option.Key] = value;
                                foreach (FSHP mesh in meshes)
                                {
                                    mesh.ReloadShader();
                                }
                            }
                        }
                    }
                    else if (ImGui.Selectable(option.Key, SelectedIndices.Contains(index)))
                    {
                        SelectedIndices.Clear();
                        SelectedIndices.Add(index);
                    }
                    ImGui.NextColumn();
                    ImGui.Text(option.Value);
                    ImGui.NextColumn();
                    index++;
                }
            }
            ImGui.EndChild();

            ImGui.Columns(1);
        }