public TexSrtPanel(TexSrtEx TexSrt, BfresShaderParam param) { InitializeComponent(); isTexSrtEx = true; 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; }
private void ReadTexSrtEx(FileReader reader) { ValueTexSrtEx = new TexSrtEx(); ValueTexSrtEx.Mode = reader.ReadEnum <TexSrtMode>(true); ValueTexSrtEx.Scaling = reader.ReadVec2SY(); ValueTexSrtEx.Rotation = reader.ReadSingle(); ValueTexSrtEx.Translation = reader.ReadVec2SY(); ValueTexSrtEx.MatrixPointer = reader.ReadUInt32(); }
/// <summary> /// /// </summary> /// <param name="reader"></param> private static void ReadTexSrtEx(BinaryDataReader reader) { ValueTexSrtEx = new TexSrtEx(); ValueTexSrtEx.Mode = reader.ReadEnum <TexSrtMode>(true); Syroot.Maths.Vector2F scaleVector2F = new Syroot.Maths.Vector2F(reader.ReadSingle(), reader.ReadSingle()); ValueTexSrtEx.Scaling = scaleVector2F; ValueTexSrtEx.Rotation = reader.ReadSingle(); Syroot.Maths.Vector2F transVector2F = new Syroot.Maths.Vector2F(reader.ReadSingle(), reader.ReadSingle()); ValueTexSrtEx.Translation = transVector2F; ValueTexSrtEx.MatrixPointer = reader.ReadUInt32(); }
private static void WriteTexSrtExParamNode(XmlDocument doc, TexSrtEx texSrtEx, string Name, XmlNode node) { XmlNode ParamNode = doc.CreateElement(Name); AddAttribute(doc, "Mode", texSrtEx.Mode.ToString(), ParamNode); AddAttribute(doc, "Scaling", texSrtEx.Scaling.ToString(), ParamNode); AddAttribute(doc, "Rotation", texSrtEx.Rotation.ToString(), ParamNode); AddAttribute(doc, "Translation", texSrtEx.Translation.ToString(), ParamNode); AddAttribute(doc, "MatrixPointer", texSrtEx.MatrixPointer.ToString(), ParamNode); AddAttribute(doc, "Format", ShaderParamType.TexSrtEx.ToString(), ParamNode); node.AppendChild(ParamNode); }
public void LoadValues(TexSrtEx 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; matrixPtrNumUD.Value = texSrt.MatrixPointer; modeComboBox.Visible = true; modeLabel.Visible = true; matrixPtrLabel.Visible = true; matrixPtrNumUD.Visible = true; }
public static TexSrtEx SetTexSRTEx(XmlNode node) { TexSrtEx texSrtEx = new TexSrtEx(); foreach (XmlAttribute att in node.Attributes) { if (att.Name == "Mode") { TexSrtMode Mode; Enum.TryParse(att.Value, out Mode); texSrtEx.Mode = Mode; } if (att.Name == "Scaling") { string[] values = GetSrtValues(att.Value); float.TryParse(values[0], out X); float.TryParse(values[1], out Y); texSrtEx.Scaling = new Syroot.Maths.Vector2F(X, Y); } if (att.Name == "Rotation") { string[] values = GetSrtValues(att.Value); float.TryParse(values[0], out X); texSrtEx.Rotation = X; } if (att.Name == "Translation") { string[] values = GetSrtValues(att.Value); float.TryParse(values[0], out X); float.TryParse(values[1], out Y); texSrtEx.Translation = new Syroot.Maths.Vector2F(X, Y); } if (att.Name == "MatrixPointer") { uint ptr; uint.TryParse(att.Value, out ptr); texSrtEx.MatrixPointer = ptr; } } return(texSrtEx); }
private string TexSrtToString(TexSrtEx val) { return($"{val.Mode} {val.Scaling.X} {val.Scaling.Y} {val.Rotation} {val.Translation.X} {val.Translation.Y} "); }
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)); } } }