private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { _mat = (CLR0MaterialNode)(listBox1.Items[listBox1.SelectedIndex] as CLR0MaterialNode); if (_mat.Children.Count > 0) { lstTarget.SelectedIndex = (int)((CLR0MaterialEntryNode)_mat.Children[0]).Target; } else { lstTarget.SelectedIndex = 0; } }
public static ResU.ShaderParamMatAnim Clr0Entry2ShaderMatAnim(CLR0Node clr0, CLR0MaterialNode clrMaterial) { ResU.ShaderParamMatAnim matAnim = new ResU.ShaderParamMatAnim(); matAnim.Name = clrMaterial.Name; foreach (var entry in clrMaterial.Children) { ushort curveIndex = 0; ushort constantIndex = 0; CLR0MaterialEntryNode ParamEntry = (CLR0MaterialEntryNode)entry; //Add constants for RGBA if constant if (ParamEntry.Constant) { //Red matAnim.Constants.Add(new ResU.AnimConstant() { AnimDataOffset = 0, Value = (float)ParamEntry.Colors[0].R / 255f, }); //Green matAnim.Constants.Add(new ResU.AnimConstant() { AnimDataOffset = 4, Value = (float)ParamEntry.Colors[0].G / 255f, }); //Blue matAnim.Constants.Add(new ResU.AnimConstant() { AnimDataOffset = 8, Value = (float)ParamEntry.Colors[0].B / 255f, }); //Alpha matAnim.Constants.Add(new ResU.AnimConstant() { AnimDataOffset = 12, Value = (float)ParamEntry.Colors[0].A / 255f, }); } var RedCurve = GenerateCurve(0, clr0, ParamEntry); var GreenCurve = GenerateCurve(4, clr0, ParamEntry); var BlueCurve = GenerateCurve(8, clr0, ParamEntry); var AlphaCurve = GenerateCurve(12, clr0, ParamEntry); if (RedCurve != null) { matAnim.Curves.Add(RedCurve); } if (GreenCurve != null) { matAnim.Curves.Add(GreenCurve); } if (BlueCurve != null) { matAnim.Curves.Add(BlueCurve); } if (AlphaCurve != null) { matAnim.Curves.Add(AlphaCurve); } matAnim.ParamAnimInfos.Add(new ResU.ParamAnimInfo() { Name = entry.Name, BeginCurve = matAnim.Curves.Count > 0 ? curveIndex : ushort.MaxValue, FloatCurveCount = (ushort)matAnim.Curves.Count, SubBindIndex = ushort.MaxValue, ConstantCount = (ushort)matAnim.Constants.Count, BeginConstant = matAnim.Constants.Count > 0 ? constantIndex : ushort.MaxValue, }); constantIndex += (ushort)matAnim.Constants.Count; curveIndex += (ushort)matAnim.Curves.Count; } return(matAnim); }