1
0
mirror of synced 2024-12-03 19:47:29 +01:00

More animation formats for wii u to switch

This commit is contained in:
KillzXGaming 2019-06-01 18:51:04 -04:00
parent e51fb070c6
commit 717822e067
7 changed files with 181 additions and 47 deletions

Binary file not shown.

View File

@ -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<ResU.TextureRef>();
if (texPatternAnim.TextureRefs == null)
texPatternAnim.TextureRefs = new ResU.ResDict<ResU.TextureRef>();
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<ResNX.UserData> ConvertUserDataWiiU2Switch(ResU.ResDict<ResU.UserData> UserDataU)
{
var UserDataNX = new List<ResNX.UserData>();
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<ResU.UserData> ConvertUserDataSwitch2WiiU(List<ResNX.UserData> UserDataNX)
{
var UserDataU = new ResU.ResDict<ResU.UserData>();
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<ResNX.AnimCurve> ConvertAnimCurveWiiUToSwitch(IList<ResU.AnimCurve> curvesU)
{
var curvesNX = new List<ResNX.AnimCurve>();
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<ResU.AnimCurve> ConvertAnimCurveSwitchToWiiU(IList<ResNX.AnimCurve> curvesNX)
{
var curvesU = new List<ResU.AnimCurve>();
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;

View File

@ -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);
}