2019-07-09 23:50:50 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Bfres.Structs;
|
|
|
|
|
using SharpYaml;
|
|
|
|
|
using SharpYaml.Serialization;
|
|
|
|
|
using Syroot.NintenTools.NSW.Bfres;
|
|
|
|
|
|
|
|
|
|
namespace FirstPlugin
|
|
|
|
|
{
|
|
|
|
|
public class YamlFmaa
|
|
|
|
|
{
|
|
|
|
|
public class AnimConfig
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public string Path { get; set; }
|
|
|
|
|
public int FrameCount { get; set; }
|
2019-07-14 01:52:04 +02:00
|
|
|
|
|
|
|
|
|
public List<MatAnimConfig> MaterialAnimConfigs = new List<MatAnimConfig>();
|
|
|
|
|
|
|
|
|
|
public AnimConfig(MaterialAnim materialAnim)
|
|
|
|
|
{
|
|
|
|
|
Name = materialAnim.Name;
|
|
|
|
|
Path = materialAnim.Path;
|
|
|
|
|
FrameCount = materialAnim.FrameCount;
|
|
|
|
|
|
|
|
|
|
foreach (var mat in materialAnim.MaterialAnimDataList)
|
|
|
|
|
{
|
|
|
|
|
MatAnimConfig matConfig = new MatAnimConfig();
|
|
|
|
|
matConfig.Name = mat.Name;
|
2019-07-14 02:20:21 +02:00
|
|
|
|
MaterialAnimConfigs.Add(matConfig);
|
2019-07-14 01:52:04 +02:00
|
|
|
|
|
|
|
|
|
foreach (var paramInfo in mat.ParamAnimInfos)
|
|
|
|
|
{
|
2019-07-14 02:20:21 +02:00
|
|
|
|
ParamInfo paramCfg = new ParamInfo();
|
|
|
|
|
paramCfg.Name = paramInfo.Name;
|
|
|
|
|
paramCfg.IsConstant = paramInfo.BeginConstant != ushort.MaxValue;
|
|
|
|
|
matConfig.ParamInfos.Add(paramCfg);
|
2019-07-14 01:52:04 +02:00
|
|
|
|
|
2019-07-14 02:20:21 +02:00
|
|
|
|
if (paramInfo.BeginCurve != ushort.MaxValue)
|
|
|
|
|
{
|
|
|
|
|
var curve = mat.Curves[(int)paramInfo.BeginCurve];
|
|
|
|
|
for (int i = 0; i < paramInfo.IntCurveCount + paramInfo.FloatCurveCount; i++)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-14 01:52:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var patternInfo in mat.TexturePatternAnimInfos)
|
|
|
|
|
{
|
|
|
|
|
PatternInfo infoCfg = new PatternInfo();
|
|
|
|
|
infoCfg.Name = patternInfo.Name;
|
|
|
|
|
infoCfg.IsConstant = patternInfo.BeginConstant != ushort.MaxValue;
|
2019-07-14 02:20:21 +02:00
|
|
|
|
matConfig.TexturePatternInfos.Add(infoCfg);
|
|
|
|
|
|
2019-07-14 02:32:30 +02:00
|
|
|
|
if (infoCfg.IsConstant)
|
|
|
|
|
{
|
|
|
|
|
infoCfg.ConstantValue = new ConstantTPConfig();
|
|
|
|
|
int Index = (int)mat.Constants[(int)patternInfo.BeginConstant].Value;
|
|
|
|
|
infoCfg.ConstantValue.Texture = materialAnim.TextureNames[Index];
|
|
|
|
|
}
|
2019-07-14 01:52:04 +02:00
|
|
|
|
if (patternInfo.CurveIndex != uint.MaxValue)
|
|
|
|
|
{
|
|
|
|
|
var curve = mat.Curves[(int)patternInfo.CurveIndex];
|
|
|
|
|
infoCfg.CurveData = new CurveTPConfig();
|
2019-07-14 02:20:21 +02:00
|
|
|
|
|
|
|
|
|
if (curve.Scale == 0)
|
|
|
|
|
curve.Scale = 1;
|
|
|
|
|
|
|
|
|
|
for (int f = 0; f < curve.Frames.Length; f++)
|
|
|
|
|
{
|
|
|
|
|
int frame = (int)curve.Frames[f];
|
|
|
|
|
int Value = (int)curve.Offset + (int)curve.Keys[f, 0] * (int)curve.Scale;
|
|
|
|
|
|
|
|
|
|
infoCfg.CurveData.KeyFrames.Add(frame, materialAnim.TextureNames[Value]);
|
|
|
|
|
}
|
2019-07-14 01:52:04 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-14 02:32:30 +02:00
|
|
|
|
public class ConstantTPConfig
|
|
|
|
|
{
|
|
|
|
|
public string Texture;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-14 01:52:04 +02:00
|
|
|
|
public class CurveTPConfig
|
|
|
|
|
{
|
2019-07-14 02:20:21 +02:00
|
|
|
|
public Dictionary<int, string> KeyFrames = new Dictionary<int, string>();
|
2019-07-09 23:50:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class MatAnimConfig
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<PatternInfo> TexturePatternInfos { get; set; }
|
|
|
|
|
public List<ParamInfo> ParamInfos { get; set; }
|
2019-07-14 02:20:21 +02:00
|
|
|
|
|
|
|
|
|
public MatAnimConfig()
|
|
|
|
|
{
|
|
|
|
|
TexturePatternInfos = new List<PatternInfo>();
|
|
|
|
|
ParamInfos = new List<ParamInfo>();
|
|
|
|
|
}
|
2019-07-09 23:50:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ParamInfo
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool IsConstant { get; set; }
|
|
|
|
|
|
|
|
|
|
public AnimCurve Curve { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class PatternInfo
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool IsConstant { get; set; }
|
2019-07-14 01:52:04 +02:00
|
|
|
|
|
2019-07-14 02:32:30 +02:00
|
|
|
|
public ConstantTPConfig ConstantValue { get; set; }
|
|
|
|
|
|
2019-07-14 01:52:04 +02:00
|
|
|
|
public CurveTPConfig CurveData { get; set; }
|
2019-07-09 23:50:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string ToYaml(string Name, FMAA anim)
|
|
|
|
|
{
|
|
|
|
|
var serializerSettings = new SerializerSettings()
|
|
|
|
|
{
|
|
|
|
|
EmitTags = false
|
|
|
|
|
};
|
|
|
|
|
|
2019-07-14 02:32:30 +02:00
|
|
|
|
serializerSettings.DefaultStyle = YamlStyle.Any;
|
|
|
|
|
serializerSettings.ComparerForKeySorting = null;
|
|
|
|
|
|
2019-07-09 23:50:50 +02:00
|
|
|
|
var MatAnim = anim.MaterialAnim;
|
2019-07-14 01:52:04 +02:00
|
|
|
|
var config = new AnimConfig(MatAnim);
|
2019-07-09 23:50:50 +02:00
|
|
|
|
|
|
|
|
|
var serializer = new Serializer(serializerSettings);
|
2019-07-14 01:52:04 +02:00
|
|
|
|
return serializer.Serialize(config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetConfig()
|
|
|
|
|
{
|
|
|
|
|
|
2019-07-09 23:50:50 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|