Beispiel #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;
            }
        }
Beispiel #2
0
        static void InsertKey(BfresMaterialAnim.ParamAnimGroup group, ShaderParamType type, float frame, object value)
        {
            //This method will insert tracks to the total amount of possible values for that parameter
            //Any unecessary values will be optimized later
            switch (type)
            {
            case ShaderParamType.TexSrt:
            case ShaderParamType.TexSrtEx:
            {
                var input = (TextureSRT)value;
                group.InsertKey(frame, 0, (int)input.Mode, 0, 0);
                group.InsertKey(frame, 4, input.ScaleX, 0, 0);
                group.InsertKey(frame, 8, input.ScaleY, 0, 0);
                group.InsertKey(frame, 12, input.Rotate, 0, 0);
                group.InsertKey(frame, 16, input.TranslateX, 0, 0);
                group.InsertKey(frame, 20, input.TranslateY, 0, 0);
            }
            break;

            case ShaderParamType.Float:
            {
                var input = (float)value;
                group.InsertKey(frame, 0, input, 0, 0);
            }
            break;

            case ShaderParamType.Float2:
            {
                var input = (Vector2)value;
                group.InsertKey(frame, 0, input.X, 0, 0);
                group.InsertKey(frame, 4, input.Y, 0, 0);
            }
            break;

            case ShaderParamType.Float3:
            {
                var input = (Vector3)value;
                group.InsertKey(frame, 0, input.X, 0, 0);
                group.InsertKey(frame, 4, input.Y, 0, 0);
                group.InsertKey(frame, 8, input.Z, 0, 0);
            }
            break;

            case ShaderParamType.Float4:
            {
                var input = (Vector4)value;
                group.InsertKey(frame, 0, input.X, 0, 0);
                group.InsertKey(frame, 4, input.Y, 0, 0);
                group.InsertKey(frame, 8, input.Z, 0, 0);
                group.InsertKey(frame, 12, input.W, 0, 0);
            }
            break;
            }
        }
Beispiel #3
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);
        }
Beispiel #4
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();
        }