Example #1
0
        public TexSrtPanel(TexSrt TexSrt, BfresShaderParam param)
        {
            InitializeComponent();

            isTexSrtEx  = false;
            activeParam = param;
            stTextBox1.Bind(activeParam, "Name");

            scalingModeCN.Bind(typeof(TexSrtMode), TexSrt, "Mode");
            scalingModeCN.SelectedItem = TexSrt.Mode;

            scaXUD.DataType   = typeof(float);
            scaYUD.DataType   = typeof(float);
            rotXUD.DataType   = typeof(float);
            transXUD.DataType = typeof(float);
            transYUD.DataType = typeof(float);

            scaXUD.Value = TexSrt.Scaling.X;
            scaYUD.Value = TexSrt.Scaling.Y;

            rotXUD.Value = TexSrt.Rotation;

            transXUD.Value = TexSrt.Translation.X;
            transYUD.Value = TexSrt.Translation.Y;
        }
Example #2
0
 private void ReadTexSrt(FileReader reader)
 {
     ValueTexSrt             = new TexSrt();
     ValueTexSrt.Mode        = reader.ReadEnum <TexSrtMode>(false);
     ValueTexSrt.Scaling     = reader.ReadVec2SY();
     ValueTexSrt.Rotation    = reader.ReadSingle();
     ValueTexSrt.Translation = reader.ReadVec2SY();
 }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="reader"></param>
 private static void ReadTexSrt(BinaryDataReader reader)
 {
     ValueTexSrt      = new TexSrt();
     ValueTexSrt.Mode = reader.ReadEnum <TexSrtMode>(false);
     Syroot.Maths.Vector2F scaleVector2F = new Syroot.Maths.Vector2F(reader.ReadSingle(), reader.ReadSingle());
     ValueTexSrt.Scaling  = scaleVector2F;
     ValueTexSrt.Rotation = reader.ReadSingle();
     Syroot.Maths.Vector2F transVector2F = new Syroot.Maths.Vector2F(reader.ReadSingle(), reader.ReadSingle());
     ValueTexSrt.Translation = transVector2F;
 }
Example #4
0
        private static void WriteTexSrtParamNode(XmlDocument doc, TexSrt texSrt, string Name, XmlNode node)
        {
            XmlNode ParamNode = doc.CreateElement(Name);

            AddAttribute(doc, "Mode", texSrt.Mode.ToString(), ParamNode);
            AddAttribute(doc, "Scaling", texSrt.Scaling.ToString(), ParamNode);
            AddAttribute(doc, "Rotation", texSrt.Rotation.ToString(), ParamNode);
            AddAttribute(doc, "Translation", texSrt.Translation.ToString(), ParamNode);
            AddAttribute(doc, "Format", ShaderParamType.TexSrt.ToString(), ParamNode);
            node.AppendChild(ParamNode);
        }
        public void LoadValues(TexSrt texSrt)
        {
            scaleUDX.Value = (decimal)texSrt.Scaling.X;
            scaleUDY.Value = (decimal)texSrt.Scaling.Y;
            rotUDX.Value   = (decimal)texSrt.Rotation;
            transUDX.Value = (decimal)texSrt.Translation.X;
            transUDY.Value = (decimal)texSrt.Translation.Y;

            modeComboBox.Items.Add(TexSrtMode.Mode3dsMax);
            modeComboBox.Items.Add(TexSrtMode.ModeMaya);
            modeComboBox.Items.Add(TexSrtMode.ModeSoftimage);
            modeComboBox.SelectedItem = texSrt.Mode;

            modeComboBox.Visible = true;
            modeLabel.Visible    = true;
        }
Example #6
0
        public static TexSrt SetTexSRT(XmlNode node)
        {
            TexSrt texSrt = new TexSrt();

            foreach (XmlAttribute att in node.Attributes)
            {
                if (att.Name == "Mode")
                {
                    TexSrtMode Mode;
                    Enum.TryParse(att.Value, out Mode);
                    texSrt.Mode = Mode;
                }
                if (att.Name == "Scaling")
                {
                    string[] values = GetSrtValues(att.Value);
                    float.TryParse(values[0], out X);
                    float.TryParse(values[1], out Y);
                    texSrt.Scaling = new Syroot.Maths.Vector2F(X, Y);
                }
                if (att.Name == "Rotation")
                {
                    string[] values = GetSrtValues(att.Value);
                    float.TryParse(values[0], out X);
                    texSrt.Rotation = X;
                }
                if (att.Name == "Translation")
                {
                    string[] values = GetSrtValues(att.Value);
                    float.TryParse(values[0], out X);
                    float.TryParse(values[1], out Y);
                    texSrt.Translation = new Syroot.Maths.Vector2F(X, Y);
                }
            }

            return(texSrt);
        }
Example #7
0
 private string TexSrtToString(TexSrt val)
 {
     return($"{val.Mode} {val.Scaling.X} {val.Scaling.Y} {val.Rotation} {val.Translation.X} {val.Translation.Y}  ");
 }
Example #8
0
        private static void SetUniformData(FMAT mat, SF.Shader shader, string propertyName)
        {
            if (mat.shaderassign.options.ContainsKey(propertyName))
            {
                float value = float.Parse(mat.shaderassign.options[propertyName]);
                shader.SetFloat(propertyName, value);
            }

            Dictionary <string, BfresShaderParam> matParams = mat.matparam;

            if (mat.animatedMatParams.ContainsKey(propertyName))
            {
                matParams = mat.animatedMatParams;
            }

            if (matParams.ContainsKey(propertyName))
            {
                if (matParams[propertyName].Type == ShaderParamType.Float)
                {
                    if (mat.anims.ContainsKey(propertyName))
                    {
                        matParams[propertyName].ValueFloat[0] = mat.anims[propertyName][0];
                    }
                    shader.SetFloat(propertyName, matParams[propertyName].ValueFloat[0]);
                }

                if (matParams[propertyName].Type == ShaderParamType.Float2)
                {
                    if (mat.anims.ContainsKey(propertyName))
                    {
                        matParams[propertyName].ValueFloat = new float[2] {
                            mat.anims[propertyName][0], mat.anims[propertyName][1]
                        };
                    }

                    shader.SetVector2(propertyName, Utils.ToVec2(matParams[propertyName].ValueFloat));
                }

                if (matParams[propertyName].Type == ShaderParamType.Float3)
                {
                    if (mat.anims.ContainsKey(propertyName))
                    {
                        matParams[propertyName].ValueFloat = new float[3] {
                            mat.anims[propertyName][0],
                            mat.anims[propertyName][1],
                            mat.anims[propertyName][2]
                        };
                    }

                    shader.SetVector3(propertyName, Utils.ToVec3(matParams[propertyName].ValueFloat));
                }
                if (matParams[propertyName].Type == ShaderParamType.Float4)
                {
                    if (mat.anims.ContainsKey(propertyName))
                    {
                        matParams[propertyName].ValueFloat = new float[4] {
                            mat.anims[propertyName][0], mat.anims[propertyName][1],
                            mat.anims[propertyName][2], mat.anims[propertyName][3]
                        };
                    }

                    shader.SetVector4(propertyName, Utils.ToVec4(matParams[propertyName].ValueFloat));
                }
                if (matParams[propertyName].Type == ShaderParamType.TexSrt)
                {
                    // Vector 2 Scale
                    // 1 roation float
                    // Vector2 translate
                    TexSrt texSRT = matParams[propertyName].ValueTexSrt;

                    shader.SetVector2("SRT_Scale", Utils.ToVec2(texSRT.Scaling));
                    shader.SetFloat("SRT_Rotate", texSRT.Rotation);
                    shader.SetVector2("SRT_Translate", Utils.ToVec2(texSRT.Translation));
                }
                if (matParams[propertyName].Type == ShaderParamType.TexSrtEx)
                {
                    // Vector 2 Scale
                    // 1 roation float
                    // Vector2 translate
                    TexSrtEx texSRT = matParams[propertyName].ValueTexSrtEx;

                    shader.SetVector2("SRT_Scale", Utils.ToVec2(texSRT.Scaling));
                    shader.SetFloat("SRT_Rotate", texSRT.Rotation);
                    shader.SetVector2("SRT_Translate", Utils.ToVec2(texSRT.Translation));
                }

                //MTA SRT
                if (propertyName == "texsrt0" && mat.shaderassign.ShaderArchive == "ssg")
                {
                    TexSrt texSRT = matParams[propertyName].ValueTexSrt;

                    shader.SetVector2("SRT_Scale", Utils.ToVec2(texSRT.Scaling));
                    shader.SetFloat("SRT_Rotate", texSRT.Rotation);
                    shader.SetVector2("SRT_Translate", Utils.ToVec2(texSRT.Translation));
                }
            }
        }
Example #9
0
        private static void SetUniformData(FMAT mat, Shader shader, string propertyName)
        {
            if (mat.shaderassign.options.ContainsKey(propertyName))
            {
                float value = float.Parse(mat.shaderassign.options[propertyName]);
                shader.SetFloat(propertyName, value);
            }
            if (mat.matparam.ContainsKey(propertyName))
            {
                if (mat.matparam[propertyName].Type == ShaderParamType.Float)
                {
                    if (mat.anims.ContainsKey(propertyName))
                    {
                        mat.matparam[propertyName].ValueFloat[0] = mat.anims[propertyName][0];
                    }
                    shader.SetFloat(propertyName, mat.matparam[propertyName].ValueFloat[0]);
                }

                if (mat.matparam[propertyName].Type == ShaderParamType.Float2)
                {
                    if (mat.anims.ContainsKey(propertyName))
                    {
                        mat.matparam[propertyName].ValueFloat = new float[2] {
                            mat.anims[propertyName][0], mat.anims[propertyName][1]
                        };
                    }

                    shader.SetVector2(propertyName, Utils.ToVec2(mat.matparam[propertyName].ValueFloat));
                }

                if (mat.matparam[propertyName].Type == ShaderParamType.Float3)
                {
                    if (mat.anims.ContainsKey(propertyName))
                    {
                        mat.matparam[propertyName].ValueFloat = new float[3] {
                            mat.anims[propertyName][0],
                            mat.anims[propertyName][1],
                            mat.anims[propertyName][2]
                        };
                    }

                    shader.SetVector3(propertyName, Utils.ToVec3(mat.matparam[propertyName].ValueFloat));
                }
                if (mat.matparam[propertyName].Type == ShaderParamType.Float4)
                {
                    if (mat.anims.ContainsKey(propertyName))
                    {
                        mat.matparam[propertyName].ValueFloat = new float[4] {
                            mat.anims[propertyName][0], mat.anims[propertyName][1],
                            mat.anims[propertyName][2], mat.anims[propertyName][3]
                        };
                    }

                    shader.SetVector4(propertyName, Utils.ToVec4(mat.matparam[propertyName].ValueFloat));
                }
                if (mat.matparam[propertyName].Type == ShaderParamType.TexSrt)
                {
                    // Vector 2 Scale
                    // 1 roation float
                    // Vector2 translate
                    TexSrt texSRT = mat.matparam[propertyName].ValueTexSrt;

                    shader.SetVector2("SRT_Scale", Utils.ToVec2(texSRT.Scaling));
                    shader.SetFloat("SRT_Rotate", texSRT.Rotation);
                    shader.SetVector2("SRT_Translate", Utils.ToVec2(texSRT.Translation));
                }
            }
        }
Example #10
0
        static void LoadParamUI(ShaderParam param, string label = "", bool drag = false)
        {
            switch (param.Type)
            {
            case ShaderParamType.Bool:
            {
                ImGuiHelper.InputFromBoolean(label, param, "DataValue");
            }
            break;

            case ShaderParamType.Int:
            {
                ImGuiHelper.InputFromInt(label, param, "DataValue", 1, drag);
            }
            break;

            case ShaderParamType.UInt:
            {
                ImGuiHelper.InputFromUint(label, param, "DataValue", 1, drag);
            }
            break;

            case ShaderParamType.Float:
            {
                ImGuiHelper.InputFromFloat(label, param, "DataValue", drag);
            }
            break;

            case ShaderParamType.Float2:
            {
                ImGuiHelper.InputFloatsFromVector2(label, param, "DataValue", drag);
            }
            break;

            case ShaderParamType.Float3:
            {
                if (param.Name.Contains("color") || param.Name.Contains("Color"))
                {
                    ImGuiHelper.InputFloatsFromColor3(label, param, "DataValue");
                }
                else
                {
                    ImGuiHelper.InputFloatsFromVector3(label, param, "DataValue", drag);
                }
            }
            break;

            case ShaderParamType.Float4:
            {
                if (param.Name.Contains("color") || param.Name.Contains("Color"))
                {
                    ImGuiHelper.InputFloatsFromColor4(label, param, "DataValue", ImGuiColorEditFlags.AlphaBar | ImGuiColorEditFlags.AlphaPreviewHalf);
                }
                else
                {
                    ImGuiHelper.InputFloatsFromVector4(label, param, "DataValue", drag);
                }
            }
            break;

            case ShaderParamType.Srt2D:
            {
                Srt2D value = (Srt2D)param.DataValue;
                var   pos   = new Vector2(value.Translation.X, value.Translation.Y);
                var   scale = new Vector2(value.Scaling.X, value.Scaling.Y);
                var   rot   = value.Rotation;

                bool edited0 = ImGui.DragFloat2("Scale", ref scale);
                bool edited1 = ImGui.DragFloat("Rotate", ref rot, 0.1f);
                bool edited2 = ImGui.DragFloat2("Translate", ref pos);
                if (edited0 || edited1 || edited2)
                {
                    param.DataValue = new Srt2D()
                    {
                        Scaling     = new Syroot.Maths.Vector2F(scale.X, scale.Y),
                        Translation = new Syroot.Maths.Vector2F(pos.X, pos.Y),
                        Rotation    = rot,
                    };
                }
            }
            break;

            case ShaderParamType.TexSrt:
            case ShaderParamType.TexSrtEx:
            {
                TexSrt value   = (TexSrt)param.DataValue;
                bool   edited3 = ImGuiHelper.ComboFromEnum <TexSrtMode>("Mode", value, "Mode");
                var    pos     = new Vector2(value.Translation.X, value.Translation.Y);
                var    scale   = new Vector2(value.Scaling.X, value.Scaling.Y);
                var    rot     = value.Rotation;

                bool edited0 = ImGui.DragFloat2("Scale", ref scale);
                bool edited1 = ImGui.DragFloat("Rotate", ref rot, 0.1f);
                bool edited2 = ImGui.DragFloat2("Translate", ref pos);
                if (edited0 || edited1 || edited2 || edited3)
                {
                    param.DataValue = new TexSrt()
                    {
                        Mode        = value.Mode,
                        Scaling     = new Syroot.Maths.Vector2F(scale.X, scale.Y),
                        Translation = new Syroot.Maths.Vector2F(pos.X, pos.Y),
                        Rotation    = rot,
                    };
                }
            }
            break;
            }
        }