Example #1
0
        static void RenderInsertPanel(BfresMaterialAnim anim, BfresMaterialAnim.ParamAnimGroup paramGroup)
        {
            ImGui.InputInt("Frame", ref frameInsert, 0);
            ImGui.NextColumn();

            //Display the value to insert into the key list if the insert button gets presse
            switch (ParamProperty.ParamType)
            {
            case ShaderParamType.Float:
                DisplayParam("##INSERT", floatInsert1);
                break;

            case ShaderParamType.Float2:
                DisplayParam("##INSERT", floatInsert2);
                break;

            case ShaderParamType.Float3:
                var editedValue = DisplayParam("##INSERT", floatInsert3);
                if (editedValue != null)
                {
                    floatInsert3 = (Vector3)editedValue;
                }
                break;

            case ShaderParamType.Float4:
                DisplayParam("##INSERT", floatInsert4);
                break;

            case ShaderParamType.TexSrtEx:
            case ShaderParamType.TexSrt:
                DisplayParam("##INSERT", texSRTtInsert);
                break;
            }
        }
Example #2
0
        public ShaderParamAnimFolder(BFRES bfres, ResFile resFile, ResDict <MaterialAnim> resDict)
        {
            foreach (MaterialAnim anim in resDict.Values)
            {
                var node = new BfresNodeBase(anim.Name);
                AddChild(node);

                var fmaa = new BfresMaterialAnim(anim, resFile.Name);
                node.Tag = fmaa;
                bfres.MaterialAnimations.Add(fmaa);
            }
        }
Example #3
0
        public TexturePatternAnimFolder(BFRES bfres, ResFile resFile, ResDict <MaterialAnim> resDict)
        {
            foreach (MaterialAnim anim in resDict.Values)
            {
                var node = new BfresNodeBase(anim.Name);
                AddChild(node);

                var fsha = new BfresMaterialAnim(anim, resFile.Name);
                node.Tag = fsha;
                bfres.MaterialAnimations.Add(fsha);
            }
        }
Example #4
0
        static void UpdateParamInfo(BfresMaterialAnim anim, STAnimGroup paramGroup)
        {
            var materials = anim.GetMaterials(SelectedMaterial);

            if (materials.Count > 0)
            {
                var mat = materials.FirstOrDefault();
                if (mat.ShaderParams.ContainsKey(paramGroup.Name))
                {
                    ParamProperty.ParamType = mat.ShaderParams[paramGroup.Name].Type;
                }
            }
            if (paramGroup.Name.Contains("color") || paramGroup.Name.Contains("Color"))
            {
                isColor = true;
            }
        }
Example #5
0
        public static void RenderParamEditor(BfresMaterialAnim anim,
                                             BfresMaterialAnim.ParamAnimGroup paramGroup)
        {
            if (ImGui.CollapsingHeader("Track Data", ImGuiTreeNodeFlags.DefaultOpen))
            {
                ImGuiHelper.ComboFromEnum <BfresLibrary.ShaderParamType>("Param Type", ParamProperty, "ParamType");

                ImGui.Checkbox("Show Full Interpolation", ref showInterpolated);

                if (ParamProperty.ParamType == ShaderParamType.Float3 ||
                    ParamProperty.ParamType == ShaderParamType.Float4)
                {
                    ImGui.Checkbox("Is Color", ref isColor);
                }
            }
            RenderColorParamEditor(anim, paramGroup);
        }
Example #6
0
        public void LoadEditor(BfresMaterialAnim anim)
        {
            if (string.IsNullOrEmpty(SelectedMaterial))
            {
                SelectedMaterial = anim.AnimGroups.FirstOrDefault().Name;
            }

            if (ImGui.CollapsingHeader("Header"))
            {
                ImGuiHelper.InputFromText("Name", anim, "Name", 200);
                ImGuiHelper.InputFromFloat("FrameCount", anim, "FrameCount");
                ImGuiHelper.InputFromBoolean("Loop", anim, "Loop");
            }

            if (ImGui.BeginCombo("Material", SelectedMaterial))
            {
                foreach (var group in anim.AnimGroups)
                {
                    bool isSelected = group.Name == SelectedMaterial;
                    if (ImGui.Selectable(group.Name) || isSelected)
                    {
                        SelectedMaterial = group.Name;
                    }

                    if (isSelected)
                    {
                        ImGui.SetItemDefaultFocus();
                    }
                }
                ImGui.EndCombo();
            }

            foreach (var group in anim.AnimGroups)
            {
                bool isSelected = group.Name == SelectedMaterial;
                if (isSelected)
                {
                    RenderMaterial(anim, (BfresMaterialAnim.MaterialAnimGroup)group);
                }
            }
        }
Example #7
0
        public static void RenderMaterial(BfresMaterialAnim anim,
                                          BfresMaterialAnim.MaterialAnimGroup group)
        {
            if (string.IsNullOrEmpty(SelectedParam))
            {
                SelectedParam = group.SubAnimGroups.FirstOrDefault().Name;
            }

            if (ImGui.BeginCombo("Params", SelectedParam))
            {
                foreach (var subgroup in group.SubAnimGroups)
                {
                    if (subgroup is BfresMaterialAnim.ParamAnimGroup)
                    {
                        bool isSelected = subgroup.Name == SelectedParam;
                        if (ImGui.Selectable(subgroup.Name) || isSelected)
                        {
                            SelectedParam = subgroup.Name;
                            UpdateParamInfo(anim, subgroup);
                        }
                        if (isSelected)
                        {
                            ImGui.SetItemDefaultFocus();
                        }
                    }
                }
                ImGui.EndCombo();
            }

            foreach (var subgroup in group.SubAnimGroups)
            {
                bool isSelected = subgroup.Name == SelectedParam;
                if (isSelected)
                {
                    RenderParamEditor(anim, (BfresMaterialAnim.ParamAnimGroup)subgroup);
                }
            }
        }
Example #8
0
        public static void RenderColorParamEditor(BfresMaterialAnim anim, BfresMaterialAnim.ParamAnimGroup paramGroup)
        {
            var tracks = paramGroup.GetTracks();

            if (ImGui.Button("Insert Key"))
            {
                var insertedValue = GetInsertValue();
                //Insert current key and data type used
                InsertKey(paramGroup, ParamProperty.ParamType, frameInsert, insertedValue);
                //Reload frame view
                anim.SetFrame(anim.Frame);
            }

            ImGui.SameLine();
            if (ImGui.Button("Remove Key"))
            {
                deleteSelected = true;
            }

            bool isTexSRT = ParamProperty.ParamType == ShaderParamType.TexSrt ||
                            ParamProperty.ParamType == ShaderParamType.TexSrtEx;

            //Do headers
            if (isTexSRT)
            {
                ImGui.Columns(7);
                ImGui.Text("Frame");
                ImGui.NextColumn();
                ImGui.Text("Mode");
                ImGui.NextColumn();
                ImGui.Text("Scale X");
                ImGui.NextColumn();
                ImGui.Text("Scale Y");
                ImGui.NextColumn();
                ImGui.Text("Rotate");
                ImGui.NextColumn();
                ImGui.Text("Translate X");
                ImGui.NextColumn();
                ImGui.Text("Translate Y");
                ImGui.NextColumn();

                ImGui.Separator();
            }
            else
            {
                ImGui.Columns(2);
                ImGui.Text("Frame");
                ImGui.NextColumn();
                ImGui.Text("Value");
                ImGui.NextColumn();
                ImGui.Separator();
            }

            RenderInsertPanel(anim, paramGroup);

            ImGui.Separator();

            ImGui.Columns(1);

            ImGui.BeginChild("##PARAM_ANIM");

            for (int i = 0; i < anim.FrameCount; i++)
            {
                if (!showInterpolated && !tracks.Any(x => x.IsKeyed(i)))
                {
                    continue;
                }

                if (isTexSRT)
                {
                    ImGui.Columns(7);
                }
                else
                {
                    ImGui.Columns(2);
                }

                if (ImGui.Selectable(i.ToString(), selectedFrames.Contains(i)))
                {
                    if (!OpenTK.Input.Keyboard.GetState().IsKeyDown(OpenTK.Input.Key.ShiftLeft))
                    {
                        selectedFrames.Clear();
                    }
                    selectedFrames.Add(i);
                }

                if (selectedFrames.Contains(i) && !shownPopup)
                {
                    if (ImGui.BeginPopupContextItem("##KEY_POPUP", ImGuiPopupFlags.MouseButtonRight))
                    {
                        shownPopup = true;

                        if (ImGui.Selectable("Delete"))
                        {
                            deleteSelected = true;
                        }
                        ImGui.EndPopup();
                    }
                }

                ImGui.NextColumn();

                var editedValue = DisplayParam($"##FRAME{i}", GetDataValue(tracks, i));
                if (editedValue != null)
                {
                    InsertKey(paramGroup, ParamProperty.ParamType, i, editedValue);

                    //Reload frame view
                    anim.SetFrame(anim.Frame);
                }

                ImGui.NextColumn();
            }

            if (deleteSelected)
            {
                foreach (var frame in selectedFrames)
                {
                    paramGroup.RemoveKey(frame);
                }
                deleteSelected = false;
            }

            shownPopup = false;

            ImGui.Columns(1);
            ImGui.EndChild();
        }