diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index c88091fc..468698c9 100644 Binary files a/.vs/Switch_Toolbox/v15/.suo and b/.vs/Switch_Toolbox/v15/.suo differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide index e1911383..041044bc 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal index 2dc03016..3ac96982 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal differ diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMAA.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMAA.cs index 7927c7a3..1a5f615a 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMAA.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMAA.cs @@ -713,7 +713,9 @@ namespace Bfres.Structs } else if (ext == ".yaml") { - + MaterialAnim = YamlFmaa.FromYaml(FileName); + MaterialAnim.Name = Text; + LoadAnim(MaterialAnim); } else if (ext == ".gif" || ext == ".png" || ext == ".apng") { diff --git a/Switch_FileFormatsMain/YAML/YamlFmaa.cs b/Switch_FileFormatsMain/YAML/YamlFmaa.cs index 43a25831..dfea1dc8 100644 --- a/Switch_FileFormatsMain/YAML/YamlFmaa.cs +++ b/Switch_FileFormatsMain/YAML/YamlFmaa.cs @@ -81,6 +81,108 @@ namespace FirstPlugin } } } + + public MaterialAnim FromYaml() + { + MaterialAnim matAnim = new MaterialAnim(); + matAnim.Name = Name; + matAnim.Path = Path; + matAnim.FrameCount = FrameCount; + matAnim.TextureNames = GenerateTextureList(); + + foreach (var matCfg in MaterialAnimConfigs) + { + var matAnimData = new MaterialAnimData(); + matAnimData.Constants = new List(); + matAnimData.Curves = new List(); + matAnimData.BeginVisalConstantIndex = 0; + + foreach (var texturePatternCfg in matCfg.TexturePatternInfos) + { + if (texturePatternCfg.IsConstant && texturePatternCfg.ConstantValue != null) + { + AnimConstant constant = new AnimConstant(); + constant.AnimDataOffset = 0; + constant.Value = matAnim.TextureNames.IndexOf(texturePatternCfg.ConstantValue.Texture); + } + else if (texturePatternCfg.CurveData != null) + { + AnimCurve curve = new AnimCurve(); + matAnimData.Curves.Add(curve); + + curve.Offset = 0; + curve.AnimDataOffset = 0; + curve.Scale = 1; + curve.CurveType = AnimCurveType.StepInt; + curve.StartFrame = 0; + + int FrameCount = texturePatternCfg.CurveData.KeyFrames.Count; + + curve.Frames = new float[FrameCount]; + curve.Keys = new float[FrameCount, 0]; + + int MaxFrame = 0; + int MaxIndex = 0; + + int i = 0; + foreach (var KeyFrame in texturePatternCfg.CurveData.KeyFrames) + { + int Index = matAnim.TextureNames.IndexOf(KeyFrame.Value); + curve.Frames[i] = KeyFrame.Key; + curve.Keys[i, 0] = Index; + + MaxFrame = Math.Max(MaxIndex, KeyFrame.Key); + MaxIndex = Math.Max(MaxIndex, Index); + + i++; + } + + if (MaxFrame < byte.MaxValue) + curve.FrameType = AnimCurveFrameType.Byte; + else if (MaxFrame < ushort.MaxValue) + curve.FrameType = AnimCurveFrameType.Decimal10x5; + else + curve.FrameType = AnimCurveFrameType.Single; + + if (MaxIndex < byte.MaxValue) + curve.KeyType = AnimCurveKeyType.SByte; + else if (MaxIndex < ushort.MaxValue) + curve.KeyType = AnimCurveKeyType.Int16; + else + curve.KeyType = AnimCurveKeyType.Single; + + } + } + + foreach (var paramCfg in matCfg.ParamInfos) + { + + } + + matAnim.MaterialAnimDataList.Add(matAnimData); + } + + return matAnim; + } + + private List GenerateTextureList() + { + List Textures = new List(); + foreach (var matCfg in MaterialAnimConfigs) + { + foreach (var texturePatternCfg in matCfg.TexturePatternInfos) + { + if (texturePatternCfg.CurveData == null) + continue; + + foreach (var KeyFrame in texturePatternCfg.CurveData.KeyFrames) + if (!Textures.Contains(KeyFrame.Value)) + Textures.Add(KeyFrame.Value); + } + } + + return Textures; + } } public class ConstantTPConfig @@ -127,6 +229,14 @@ namespace FirstPlugin public CurveTPConfig CurveData { get; set; } } + public static MaterialAnim FromYaml(string Name) + { + var serializer = new Serializer(); + var config = serializer.Deserialize(Name); + + return ((AnimConfig)config).FromYaml(); + } + public static string ToYaml(string Name, FMAA anim) { var serializerSettings = new SerializerSettings() diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index 9e464e45..a3758d1f 100644 Binary files a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache and b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache differ