diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index d0070a8d..d3e030c8 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 c02c851c..0439471d 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 84c0a411..bbce6149 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/BfresPlatformConverter.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/BfresPlatformConverter.cs index b8c362cb..ad17922d 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/BfresPlatformConverter.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/BfresPlatformConverter.cs @@ -10,8 +10,127 @@ namespace FirstPlugin { public class BfresPlatformConverter { + //Todo. Bake sizes are altered in switch somewhat, although mostly all animations should be fine - public static ResNX.SkeletalAnim ConvertWiiUToSwitch(ResU.SkeletalAnim skeletalAnimU) + public static ResNX.MaterialAnim FTXPConvertWiiUToSwitch(ResU.TexPatternAnim texPatternAnim) + { + //Different versions use different lists + if (texPatternAnim.TextureRefNames == null) + texPatternAnim.TextureRefNames = new List(); + if (texPatternAnim.TextureRefs == null) + texPatternAnim.TextureRefs = new ResU.ResDict(); + + ResNX.MaterialAnim matAnim = new ResNX.MaterialAnim(); + matAnim.Name = texPatternAnim.Name; + matAnim.Path = texPatternAnim.Path; + matAnim.FrameCount = texPatternAnim.FrameCount; + matAnim.BindIndices = texPatternAnim.BindIndices; + matAnim.BakedSize = texPatternAnim.BakedSize; + matAnim.Loop = texPatternAnim.Flags.HasFlag(ResU.TexPatternAnimFlags.Looping); + + foreach (var texRef in texPatternAnim.TextureRefNames) + matAnim.TextureNames.Add(texRef.Name); + + foreach (var texRef in texPatternAnim.TextureRefs) + matAnim.TextureNames.Add(texRef.Key); + + int CurveIndex = 0; + for (int m = 0; m < texPatternAnim.TexPatternMatAnims.Count; m++) + { + ResNX.MaterialAnimData matAnimData = new ResNX.MaterialAnimData(); + matAnimData.Name = texPatternAnim.TexPatternMatAnims[m].Name; + matAnimData.TexturePatternCurveIndex = 0; + + foreach (var patternInfoU in texPatternAnim.TexPatternMatAnims[m].PatternAnimInfos) + { + ResNX.TexturePatternAnimInfo animInfo = new ResNX.TexturePatternAnimInfo(); + animInfo.Name = patternInfoU.Name; + animInfo.CurveIndex = (uint)patternInfoU.CurveIndex; + animInfo.BeginConstant = (ushort)patternInfoU.SubBindIndex; + matAnimData.TexturePatternAnimInfos.Add(animInfo); + } + + if (texPatternAnim.TexPatternMatAnims[m].Curves.Count == 0) + { + foreach (var baseData in texPatternAnim.TexPatternMatAnims[m].BaseDataList) + { + //Add base values as constants + matAnimData.Constants.Add(new ResNX.AnimConstant() + { + Value = (int)baseData, + AnimDataOffset = 0, + }); + } + } + else + { + CurveIndex++; + matAnimData.Curves = ConvertAnimCurveWiiUToSwitch(texPatternAnim.TexPatternMatAnims[m].Curves); + } + + matAnim.MaterialAnimDataList.Add(matAnimData); + } + + matAnim.TextureBindArray = new long[matAnim.TextureNames.Count]; + for (int i = 0; i < matAnim.TextureNames.Count; i++) + matAnim.TextureBindArray[i] = -1; + + matAnim.UserData = ConvertUserDataWiiU2Switch(texPatternAnim.UserData); + + return matAnim; + } + + private static List ConvertUserDataWiiU2Switch(ResU.ResDict UserDataU) + { + var UserDataNX = new List(); + for (int i = 0; i < UserDataU.Count; i++) + { + var userData = new ResNX.UserData(); + userData.Name = UserDataU[i].Name; + + if (UserDataU[i].Type == ResU.UserDataType.Byte) + userData.SetValue(UserDataU[i].GetValueByteArray()); + if (UserDataU[i].Type == ResU.UserDataType.Int32) + userData.SetValue(UserDataU[i].GetValueInt32Array()); + if (UserDataU[i].Type == ResU.UserDataType.Single) + userData.SetValue(UserDataU[i].GetValueSingleArray()); + if (UserDataU[i].Type == ResU.UserDataType.String) + userData.SetValue(UserDataU[i].GetValueStringArray()); + if (UserDataU[i].Type == ResU.UserDataType.WString) + userData.SetValue(UserDataU[i].GetValueStringArray()); + + UserDataNX.Add(userData); + } + + return UserDataNX; + } + + private static ResU.ResDict ConvertUserDataSwitch2WiiU(List UserDataNX) + { + var UserDataU = new ResU.ResDict(); + for (int i = 0; i < UserDataNX.Count; i++) + { + var userData = new ResU.UserData(); + userData.Name = UserDataNX[i].Name; + + if (UserDataNX[i].Type == ResNX.UserDataType.Byte) + userData.SetValue(UserDataNX[i].GetValueByteArray()); + if (UserDataNX[i].Type == ResNX.UserDataType.Int32) + userData.SetValue(UserDataNX[i].GetValueInt32Array()); + if (UserDataNX[i].Type == ResNX.UserDataType.Single) + userData.SetValue(UserDataNX[i].GetValueSingleArray()); + if (UserDataNX[i].Type == ResNX.UserDataType.String) + userData.SetValue(UserDataNX[i].GetValueStringArray()); + if (UserDataNX[i].Type == ResNX.UserDataType.WString) + userData.SetValue(UserDataNX[i].GetValueStringArray()); + + UserDataU.Add(userData.Name, userData); + } + + return UserDataU; + } + + public static ResNX.SkeletalAnim FSKAConvertWiiUToSwitch(ResU.SkeletalAnim skeletalAnimU) { ResNX.SkeletalAnim ska = new ResNX.SkeletalAnim(); ska.Name = skeletalAnimU.Name; @@ -48,32 +167,65 @@ namespace FirstPlugin boneAnim.FlagsBase = (ResNX.BoneAnimFlagsBase)boneAnimU.FlagsBase; boneAnim.FlagsCurve = (ResNX.BoneAnimFlagsCurve)boneAnimU.FlagsCurve; boneAnim.FlagsTransform = (ResNX.BoneAnimFlagsTransform)boneAnimU.FlagsTransform; - - foreach (var curveU in boneAnimU.Curves) - { - ResNX.AnimCurve curve = new ResNX.AnimCurve(); - curve.AnimDataOffset = curveU.AnimDataOffset; - curve.CurveType = (ResNX.AnimCurveType)curveU.CurveType; - curve.Delta = curveU.Delta; - curve.EndFrame = curveU.EndFrame; - curve.Frames = curveU.Frames; - curve.Keys = curveU.Keys; - curve.KeyStepBoolData = curveU.KeyStepBoolData; - curve.KeyType = (ResNX.AnimCurveKeyType)curveU.KeyType; - curve.FrameType = (ResNX.AnimCurveFrameType)curveU.FrameType; - curve.StartFrame = curveU.StartFrame; - curve.Scale = curveU.Scale; - curve.Offset = (float)curveU.Offset; - - boneAnim.Curves.Add(curve); - } + boneAnim.Curves = ConvertAnimCurveWiiUToSwitch(boneAnimU.Curves); } return ska; } + private static IList ConvertAnimCurveWiiUToSwitch(IList curvesU) + { + var curvesNX = new List(); - public static ResU.SkeletalAnim ConvertSwitchToWiiU(ResNX.SkeletalAnim skeletalAnimNX) + foreach (var curveU in curvesU) + { + ResNX.AnimCurve curve = new ResNX.AnimCurve(); + curve.AnimDataOffset = curveU.AnimDataOffset; + curve.CurveType = (ResNX.AnimCurveType)curveU.CurveType; + curve.Delta = curveU.Delta; + curve.EndFrame = curveU.EndFrame; + curve.Frames = curveU.Frames; + curve.Keys = curveU.Keys; + curve.KeyStepBoolData = curveU.KeyStepBoolData; + curve.KeyType = (ResNX.AnimCurveKeyType)curveU.KeyType; + curve.FrameType = (ResNX.AnimCurveFrameType)curveU.FrameType; + curve.StartFrame = curveU.StartFrame; + curve.Scale = curveU.Scale; + curve.Offset = (float)curveU.Offset; + + curvesNX.Add(curve); + } + + return curvesNX; + } + + private static IList ConvertAnimCurveSwitchToWiiU(IList curvesNX) + { + var curvesU = new List(); + + foreach (var curveNX in curvesNX) + { + ResU.AnimCurve curve = new ResU.AnimCurve(); + curve.AnimDataOffset = curveNX.AnimDataOffset; + curve.CurveType = (ResU.AnimCurveType)curveNX.CurveType; + curve.Delta = curveNX.Delta; + curve.EndFrame = curveNX.EndFrame; + curve.Frames = curveNX.Frames; + curve.Keys = curveNX.Keys; + curve.KeyStepBoolData = curveNX.KeyStepBoolData; + curve.KeyType = (ResU.AnimCurveKeyType)curveNX.KeyType; + curve.FrameType = (ResU.AnimCurveFrameType)curveNX.FrameType; + curve.StartFrame = curveNX.StartFrame; + curve.Scale = curveNX.Scale; + curve.Offset = (float)curveNX.Offset; + + curvesU.Add(curve); + } + + return curvesU; + } + + public static ResU.SkeletalAnim FSKAConvertSwitchToWiiU(ResNX.SkeletalAnim skeletalAnimNX) { ResU.SkeletalAnim ska = new ResU.SkeletalAnim(); ska.Name = skeletalAnimNX.Name; @@ -110,25 +262,7 @@ namespace FirstPlugin boneAnimU.FlagsBase = (ResU.BoneAnimFlagsBase)boneAnimNX.FlagsBase; boneAnimU.FlagsCurve = (ResU.BoneAnimFlagsCurve)boneAnimNX.FlagsCurve; boneAnimU.FlagsTransform = (ResU.BoneAnimFlagsTransform)boneAnimNX.FlagsTransform; - - foreach (var curveNX in boneAnimNX.Curves) - { - ResU.AnimCurve curve = new ResU.AnimCurve(); - curve.AnimDataOffset = curveNX.AnimDataOffset; - curve.CurveType = (ResU.AnimCurveType)curveNX.CurveType; - curve.Delta = curveNX.Delta; - curve.EndFrame = curveNX.EndFrame; - curve.Frames = curveNX.Frames; - curve.Keys = curveNX.Keys; - curve.KeyStepBoolData = curveNX.KeyStepBoolData; - curve.KeyType = (ResU.AnimCurveKeyType)curveNX.KeyType; - curve.FrameType = (ResU.AnimCurveFrameType)curveNX.FrameType; - curve.StartFrame = curveNX.StartFrame; - curve.Scale = curveNX.Scale; - curve.Offset = (float)curveNX.Offset; - - boneAnimU.Curves.Add(curve); - } + boneAnimU.Curves = ConvertAnimCurveSwitchToWiiU(boneAnimNX.Curves); } return ska; diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs index cbe0ea86..c6e0e49a 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs @@ -126,7 +126,7 @@ namespace Bfres.Structs STSkeleton skeleton = GetActiveSkeleton(); if (SkeletalAnimU != null) - BrawlboxHelper.FSKAConverter.Fska2Chr0(BfresPlatformConverter.ConvertWiiUToSwitch(SkeletalAnimU), FileName); + BrawlboxHelper.FSKAConverter.Fska2Chr0(BfresPlatformConverter.FSKAConvertWiiUToSwitch(SkeletalAnimU), FileName); else BrawlboxHelper.FSKAConverter.Fska2Chr0(SkeletalAnim, FileName); @@ -217,7 +217,7 @@ namespace Bfres.Structs { var ska = new SkeletalAnim(); ska.Import(FileName); - SkeletalAnimU = BfresPlatformConverter.ConvertSwitchToWiiU(ska); + SkeletalAnimU = BfresPlatformConverter.FSKAConvertSwitchToWiiU(ska); SkeletalAnimU.Name = Text; LoadAnim(SkeletalAnimU); } @@ -241,7 +241,7 @@ namespace Bfres.Structs //Create a new wii u skeletal anim and try to convert it instead var ska = new ResU.SkeletalAnim(); ska.Import(FileName, new ResU.ResFile()); - SkeletalAnim = BfresPlatformConverter.ConvertWiiUToSwitch(ska); + SkeletalAnim = BfresPlatformConverter.FSKAConvertWiiUToSwitch(ska); SkeletalAnim.Name = Text; LoadAnim(SkeletalAnim); } @@ -296,7 +296,7 @@ namespace Bfres.Structs { if (IsWiiU) { - SkeletalAnimU = BfresPlatformConverter.ConvertSwitchToWiiU(FromGeneric(anims[i])); + SkeletalAnimU = BfresPlatformConverter.FSKAConvertSwitchToWiiU(FromGeneric(anims[i])); LoadAnim(SkeletalAnimU); } else @@ -315,7 +315,7 @@ namespace Bfres.Structs if (SkeletalAnimU != null) { - SkeletalAnimU = BfresPlatformConverter.ConvertSwitchToWiiU(ska); + SkeletalAnimU = BfresPlatformConverter.FSKAConvertSwitchToWiiU(ska); LoadAnim(SkeletalAnimU); } else @@ -778,7 +778,7 @@ namespace Bfres.Structs if (SkeletalAnimU != null) { var SkeletalAnimNX = BrawlboxHelper.FSKAConverter.Anim2Fska(FileName); - SkeletalAnimU = BfresPlatformConverter.ConvertSwitchToWiiU(SkeletalAnimNX); + SkeletalAnimU = BfresPlatformConverter.FSKAConvertSwitchToWiiU(SkeletalAnimNX); SkeletalAnimU.Name = Text; LoadAnim(SkeletalAnimU); } @@ -795,7 +795,7 @@ namespace Bfres.Structs if (IsWiiU) { var SkeletalAnimNX = BrawlboxHelper.FSKAConverter.Chr02Fska(FileName); - SkeletalAnimU = BfresPlatformConverter.ConvertSwitchToWiiU(SkeletalAnimNX); + SkeletalAnimU = BfresPlatformConverter.FSKAConvertSwitchToWiiU(SkeletalAnimNX); SkeletalAnimU.Name = Text; LoadAnim(SkeletalAnimU); } diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index 786b940c..491c9b46 100644 Binary files a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache and b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache index 4d30a5fa..13a0a888 100644 Binary files a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache and b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache differ