コード例 #1
0
        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();
            }
        }
コード例 #2
0
        public TextureMapEditor()
        {
            InitializeComponent();

            uvViewport1      = new UVViewport();
            uvViewport1.Dock = DockStyle.Fill;
            viewportPanel.Controls.Add(uvViewport1);

            stDropDownPanel1.ResetColors();
            stDropDownPanel2.ResetColors();

            imgListSmall = new ImageList()
            {
                ImageSize  = new Size(30, 30),
                ColorDepth = ColorDepth.Depth32Bit,
            };
            imgListBig = new ImageList()
            {
                ColorDepth = ColorDepth.Depth32Bit,
                ImageSize  = new Size(40, 40),
            };
        }
コード例 #3
0
 public void Init()
 {
     UVViewport             = new UVViewport();
     UVViewport.Camera.Zoom = 30;
     UVViewport.OnLoad();
 }
コード例 #4
0
        public static void Render(FMAT material, UVViewport UVViewport, bool onLoad)
        {
            float width = ImGui.GetWindowWidth();

            if (ImGui.BeginChild("TEXTURE_MAP_LIST", new System.Numerics.Vector2(width, 100)))
            {
                int index = 0;
                foreach (var texMap in material.TextureMaps)
                {
                    var tex = SearchTextureInstance(texMap.Name);
                    if (tex != null)
                    {
                        if (tex.RenderableTex == null)
                        {
                            tex.LoadRenderableTexture();
                        }

                        if (tex.RenderableTex != null)
                        {
                            IconManager.LoadTexture(tex.Name, tex);
                        }
                        else
                        {
                            IconManager.LoadIcon("TEXTURE");
                        }
                    }
                    else
                    {
                        IconManager.LoadIcon("TEXTURE");
                    }
                    ImGui.SameLine();

                    if (dialogOpened && SelectedIndices.Contains(index))
                    {
                        if (TextureSelectionDialog.Render(texMap.Name, ref dialogOpened))
                        {
                            var input = TextureSelectionDialog.OutputName;
                            //Only undo matching textures, not typed names
                            if (tex != null)
                            {
                                UndoStack.Add(new UndoStringOperation($"Texture Map",
                                                                      texMap, "Name", input));
                            }

                            texMap.Name = input;
                        }
                    }
                    else
                    {
                        if (ImGui.Selectable(texMap.Name, SelectedIndices.Contains(index)))
                        {
                            SelectedIndices.Clear();
                            SelectedIndices.Add(index);
                        }
                        if (ImGui.IsItemClicked() && ImGui.IsMouseDoubleClicked(0))
                        {
                            dialogOpened = true;
                        }
                    }

                    index++;
                }
            }
            ImGui.EndChild();

            if (material.TextureMaps.Count == 0)
            {
                return;
            }

            //Make sure there is atleast 1 selection used
            if (SelectedIndices.Count == 0)
            {
                SelectedIndices.Add(0);
            }

            if (ImGui.BeginChild("SAMPLER_DATA"))
            {
                SelectSampler(material, UVViewport, SelectedIndices.FirstOrDefault(), onLoad);
            }
            ImGui.EndChild();
        }