diff --git a/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FSHU.cs b/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FSHU.cs index fbc22e37..8b6d2b9d 100644 --- a/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FSHU.cs +++ b/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FSHU.cs @@ -62,19 +62,35 @@ namespace Bfres.Structs ShaderParamAnim.Name = Text; LoadAnim(ShaderParamAnim, AnimationType.ShaderParam); } - if (ext == ".bfcsh") + else if (ext == ".bfcsh") { ShaderParamAnim.Import(FileName, resFile, ShaderParamAnimType.Color); ShaderParamAnim.Name = Text; LoadAnim(ShaderParamAnim, AnimationType.Color); } - if (ext == ".bftsh") + else if (ext == ".bftsh") { ShaderParamAnim.Import(FileName, resFile, ShaderParamAnimType.TextureSRT); ShaderParamAnim.Name = Text; LoadAnim(ShaderParamAnim, AnimationType.TexturePattern); } - if (ext == ".clr0") + else if (ext == ".bfmaa") + { + var fmaa = new Syroot.NintenTools.NSW.Bfres.MaterialAnim(); ; + fmaa.Import(FileName); + ShaderParamAnim = BfresPlatformConverter.FSHUConvertSwitchToWiiU(fmaa); + ShaderParamAnim.Name = Text; + LoadAnim(ShaderParamAnim, AnimationType.ShaderParam); + } + else if (ext == ".yaml") + { + var fmaa = new Syroot.NintenTools.NSW.Bfres.MaterialAnim(); + fmaa = YamlFmaa.FromYaml(FileName); + ShaderParamAnim = BfresPlatformConverter.FSHUConvertSwitchToWiiU(fmaa); + ShaderParamAnim.Name = Text; + LoadAnim(ShaderParamAnim, AnimationType.ShaderParam); + } + else if (ext == ".clr0") { ShaderParamAnim = BrawlboxHelper.FSHUConverter.Clr02Fshu(FileName); ShaderParamAnim.Name = Text; @@ -101,15 +117,25 @@ namespace Bfres.Structs { ShaderParamAnim.Export(FileName, GetResFile(), ShaderParamAnimType.ShaderParameter); } - if (ext == ".bfcsh") + else if (ext == ".bfcsh") { ShaderParamAnim.Export(FileName, GetResFile(), ShaderParamAnimType.Color); } - if (ext == ".bftsh") + else if (ext == ".bftsh") { ShaderParamAnim.Export(FileName, GetResFile(), ShaderParamAnimType.TextureSRT); } - if (ext == ".clr0") + else if (ext == ".bfmaa") + { + var fmaa = BfresPlatformConverter.FSHUConvertWiiUToSwitch(ShaderParamAnim); + fmaa.Export(FileName, new Syroot.NintenTools.NSW.Bfres.ResFile()); + } + else if (ext == ".yaml") + { + var yaml = YamlFmaa.ToYaml(FileName, BfresPlatformConverter.FSHUConvertWiiUToSwitch(ShaderParamAnim), AnimationType.ShaderParam); + System.IO.File.WriteAllText(FileName, yaml); + } + else if (ext == ".clr0") { } } diff --git a/File_Format_Library/FileFormats/BFRES/PlatformConverter/BfresPlatformConverter.cs b/File_Format_Library/FileFormats/BFRES/PlatformConverter/BfresPlatformConverter.cs index 2305ed47..8decff00 100644 --- a/File_Format_Library/FileFormats/BFRES/PlatformConverter/BfresPlatformConverter.cs +++ b/File_Format_Library/FileFormats/BFRES/PlatformConverter/BfresPlatformConverter.cs @@ -72,6 +72,53 @@ namespace FirstPlugin return matAnim; } + + public static ResU.ShaderParamAnim FSHUConvertSwitchToWiiU(ResNX.MaterialAnim materialAnim) + { + var shaderParamAnim = new ResU.ShaderParamAnim(); + shaderParamAnim.Name = materialAnim.Name; + shaderParamAnim.Path = materialAnim.Path; + shaderParamAnim.BindIndices = materialAnim.BindIndices; + shaderParamAnim.FrameCount = materialAnim.FrameCount; + if (materialAnim.Loop) + shaderParamAnim.Flags |= ResU.ShaderParamAnimFlags.Looping; + + for (int m = 0; m < materialAnim.MaterialAnimDataList.Count; m++) + { + if (materialAnim.MaterialAnimDataList[m].Constants == null) + materialAnim.MaterialAnimDataList[m].Constants = new List(); + if (materialAnim.MaterialAnimDataList[m].Curves == null) + materialAnim.MaterialAnimDataList[m].Curves = new List(); + + ResU.ShaderParamMatAnim matAnimData = new ResU.ShaderParamMatAnim(); + shaderParamAnim.ShaderParamMatAnims.Add(matAnimData); + matAnimData.Name = materialAnim.MaterialAnimDataList[m].Name; + matAnimData.Curves = ConvertAnimCurveSwitchToWiiU(materialAnim.MaterialAnimDataList[m].Curves); + + foreach (var constants in materialAnim.MaterialAnimDataList[m].Constants) + { + matAnimData.Constants.Add(new ResU.AnimConstant() + { + AnimDataOffset = constants.AnimDataOffset, + Value = (float)constants.Value, + }); + } + + foreach (var paramInfoNX in materialAnim.MaterialAnimDataList[m].ParamAnimInfos) + { + var paramInfoU = new ResU.ParamAnimInfo(); + paramInfoU.Name = paramInfoNX.Name; + paramInfoU.BeginCurve = paramInfoNX.BeginCurve; + paramInfoU.BeginConstant = paramInfoNX.BeginConstant; + paramInfoU.FloatCurveCount = paramInfoNX.FloatCurveCount; + paramInfoU.IntCurveCount = paramInfoNX.IntCurveCount; + paramInfoU.SubBindIndex = paramInfoNX.SubBindIndex; + matAnimData.ParamAnimInfos.Add(paramInfoU); + } + } + + return shaderParamAnim; + } public static ResNX.MaterialAnim FSHUConvertWiiUToSwitch(ResU.ShaderParamAnim ShaderAnim) { diff --git a/File_Format_Library/NodeWrappers/BfresFilters.cs b/File_Format_Library/NodeWrappers/BfresFilters.cs index 676dc587..060894a3 100644 --- a/File_Format_Library/NodeWrappers/BfresFilters.cs +++ b/File_Format_Library/NodeWrappers/BfresFilters.cs @@ -26,12 +26,12 @@ namespace FirstPlugin public static string FMAA = GetFilter(".bfmaa",".yaml", ".gif"); - public static string FSHU_REPLACE_PARAM = GetFilter(".bfmaa", ".bfshu"); - public static string FSHU_REPLACE_SRT = GetFilter(".bfmaa", ".bftsh"); - public static string FSHU_REPLACE_COLOR = GetFilter(".bfmaa", ".bfcsh", ".clr0"); - public static string FSHU_EXPORT_PARAM = GetFilter(".bfmaa", ".bfshu"); - public static string FSHU_EXPORT_SRT = GetFilter(".bfmaa", ".bftsh"); - public static string FSHU_EXPORT_COLOR = GetFilter(".bfmaa", ".bfcsh"); + public static string FSHU_REPLACE_PARAM = GetFilter(".bfmaa", ".bfshu", ".yaml"); + public static string FSHU_REPLACE_SRT = GetFilter(".bfmaa", ".bftsh", ".yaml"); + public static string FSHU_REPLACE_COLOR = GetFilter(".bfmaa", ".bfcsh", ".yaml", ".clr0"); + public static string FSHU_EXPORT_PARAM = GetFilter(".bfmaa", ".bfshu", ".yaml"); + public static string FSHU_EXPORT_SRT = GetFilter(".bfmaa", ".bftsh", ".yaml"); + public static string FSHU_EXPORT_COLOR = GetFilter(".bfmaa", ".bfcsh", ".yaml"); public static string FCLH = GetFilter(".bfcsh"); public static string FSTH = GetFilter(".bfsth");