1
0
mirror of synced 2024-11-14 11:07:39 +01:00

Convert wii u and switch texture pattern animations

This commit is contained in:
KillzXGaming 2019-07-14 13:22:59 -04:00
parent 3312f5ab00
commit a08d878d45
10 changed files with 80 additions and 6 deletions

Binary file not shown.

View File

@ -720,7 +720,7 @@ namespace Bfres.Structs
}
else if (ext == ".yaml")
{
System.IO.File.WriteAllText(FileName, YamlFmaa.ToYaml(FileName, this));
System.IO.File.WriteAllText(FileName, YamlFmaa.ToYaml(FileName, MaterialAnim));
}
}
public override void Replace(string FileName)

View File

@ -226,7 +226,21 @@ namespace Bfres.Structs
public override void Export(string FileName)
{
TexPatternAnim.Export(FileName, GetResFile());
string ext = Utils.GetExtension(FileName);
if (ext == ".bftxp")
{
TexPatternAnim.Export(FileName, GetResFile());
}
else if (ext == ".bfmaa")
{
var fmaa = BfresPlatformConverter.FTXPConvertWiiUToSwitch(TexPatternAnim);
fmaa.Export(FileName, new Syroot.NintenTools.NSW.Bfres.ResFile());
}
else if (ext == ".yaml")
{
var yaml = YamlFmaa.ToYaml(FileName, BfresPlatformConverter.FTXPConvertWiiUToSwitch(TexPatternAnim));
System.IO.File.WriteAllText(FileName, yaml);
}
}
public override void Replace(string FileName) {
@ -239,10 +253,25 @@ namespace Bfres.Structs
if (ext == ".bftxp")
{
TexPatternAnim.Import(FileName, resFile);
bool IsSwitch = BfresUtilies.IsSubSectionSwitch(FileName);
if (IsSwitch)
{
var fmaa = new Syroot.NintenTools.NSW.Bfres.MaterialAnim();
fmaa.Import(FileName);
TexPatternAnim = BfresPlatformConverter.FTXPConvertSwitchToWiiU(fmaa);
}
else
TexPatternAnim.Import(FileName, resFile);
TexPatternAnim.Name = Text;
LoadAnim(TexPatternAnim);
}
else if (ext == ".yaml")
{
var fmaa = new Syroot.NintenTools.NSW.Bfres.MaterialAnim();
fmaa = YamlFmaa.FromYaml(FileName);
TexPatternAnim = BfresPlatformConverter.FTXPConvertSwitchToWiiU(fmaa);
}
else if (ext == ".gif")
{
BFRESGroupNode ftexFolder = PluginRuntime.ftexContainers[0];

View File

@ -131,6 +131,51 @@ namespace FirstPlugin
return matAnim;
}
public static ResU.TexPatternAnim FTXPConvertSwitchToWiiU(ResNX.MaterialAnim materialAnim)
{
var texPatternAnim = new ResU.TexPatternAnim();
//Different versions use different lists
if (texPatternAnim.TextureRefNames == null)
texPatternAnim.TextureRefNames = new List<ResU.TextureRef>();
if (texPatternAnim.TextureRefs == null)
texPatternAnim.TextureRefs = new ResU.ResDict<ResU.TextureRef>();
texPatternAnim.Name = materialAnim.Name;
texPatternAnim.Path = materialAnim.Path;
texPatternAnim.BindIndices = materialAnim.BindIndices;
//Fill both lists. On save only one will be used depending on version
foreach (var texName in materialAnim.TextureNames)
{
texPatternAnim.TextureRefNames.Add(new ResU.TextureRef() { Name = texName });
texPatternAnim.TextureRefs.Add(texName, new ResU.TextureRef() { Name = texName });
}
for (int m = 0; m < materialAnim.MaterialAnimDataList.Count; m++)
{
ResU.TexPatternMatAnim matAnimData = new ResU.TexPatternMatAnim();
matAnimData.Name = materialAnim.MaterialAnimDataList[m].Name;
matAnimData.Curves = ConvertAnimCurveSwitchToWiiU(materialAnim.MaterialAnimDataList[m].Curves);
foreach (var constants in materialAnim.MaterialAnimDataList[m].Constants)
{
matAnimData.BaseDataList.Add((ushort)(int)constants.Value);
}
foreach (var patternInfoNX in materialAnim.MaterialAnimDataList[m].TexturePatternAnimInfos)
{
var patternInfoU = new ResU.PatternAnimInfo();
patternInfoU.Name = patternInfoNX.Name;
patternInfoU.CurveIndex = (sbyte)patternInfoNX.CurveIndex;
patternInfoU.SubBindIndex = patternInfoNX.SubBindIndex;
matAnimData.PatternAnimInfos.Add(patternInfoU);
}
}
return texPatternAnim;
}
public static ResNX.MaterialAnim FTXPConvertWiiUToSwitch(ResU.TexPatternAnim texPatternAnim)
{
//Different versions use different lists

View File

@ -35,7 +35,7 @@ namespace FirstPlugin
public static string FCLH = GetFilter(".bfcsh");
public static string FSTH = GetFilter(".bfsth");
public static string FTXP = GetFilter(".bftxp", ".gif");
public static string FTXP = GetFilter(".bftxp", ".yaml", ".gif");
public static string FMTV = GetFilter(".bfmvi");
public static string FBNV = GetFilter(".bfbvi");
public static string FSCN = GetFilter(".bfscn");
@ -134,6 +134,7 @@ namespace FirstPlugin
case ".chr0": filters.Add(ext, "CHR0 Animation"); break;
case ".anim": filters.Add(ext, "Maya Animation"); break;
case ".yaml": filters.Add(ext, "Yet Another Markup Language"); break;
case ".gif": filters.Add(ext, "Graphics Interchange Format"); break;
default:
filters.Add(ext, ""); break;
}

View File

@ -308,7 +308,7 @@ namespace FirstPlugin
return config.FromYaml();
}
public static string ToYaml(string Name, FMAA anim)
public static string ToYaml(string Name, MaterialAnim MatAnim)
{
var serializerSettings = new SerializerSettings()
{
@ -319,7 +319,6 @@ namespace FirstPlugin
serializerSettings.ComparerForKeySorting = null;
serializerSettings.RegisterTagMapping("AnimConfig", typeof(AnimConfig));
var MatAnim = anim.MaterialAnim;
var config = new AnimConfig();
config.ToYaml(MatAnim);