public void CreateSampler(string Name, bool IsConstant) { var mat = MaterialAnimData; var SamplerInfo = new TexturePatternAnimInfo(); if (IsConstant) { SamplerInfo.BeginConstant = (ushort)mat.Constants.Count; SamplerInfo.CurveIndex = (ushort)65535; } else { SamplerInfo.BeginConstant = (ushort)65535; SamplerInfo.CurveIndex = (ushort)mat.Curves.Count; } mat.TexturePatternAnimInfos.Add(SamplerInfo); BfresSamplerAnim sampler = new BfresSamplerAnim(SamplerInfo.Name, matAnimWrapper, this); Samplers.Add(sampler); }
private void LoadAnim(MaterialAnim anim) { Initialize(); MaterialAnim = anim; FrameCount = MaterialAnim.FrameCount; Text = anim.Name; Textures.Clear(); if (anim.TextureNames != null) { foreach (var name in anim.TextureNames) { Textures.Add(name); } } Materials.Clear(); foreach (var matanim in anim.MaterialAnimDataList) { var mat = new MaterialAnimEntry(matanim.Name); mat.MaterialAnimData = matanim; Materials.Add(mat); foreach (var param in matanim.ParamAnimInfos) { FSHU.BfresParamAnim paramInfo = new FSHU.BfresParamAnim(param.Name); mat.Params.Add(paramInfo); paramInfo.Type = AnimationType.ShaderParam; //There is no better way to determine if the param is a color type afaik if (param.Name.Contains("Color") || param.Name.Contains("color") || param.Name == "multi_tex_reg2") { paramInfo.Type = AnimationType.Color; } else if (AnimType == AnimationType.TexturePattern) { paramInfo.Type = AnimationType.TexturePattern; } else if (AnimType == AnimationType.TextureSrt) { paramInfo.Type = AnimationType.TextureSrt; } else { paramInfo.Type = AnimationType.ShaderParam; } //Get constant anims for (int constant = 0; constant < param.ConstantCount; constant++) { int index = constant + param.BeginConstant; Animation.KeyGroup keyGroup = new Animation.KeyGroup(); keyGroup.Keys.Add(new Animation.KeyFrame() { InterType = InterpolationType.CONSTANT, Frame = 0, Value = matanim.Constants[index].Value, }); paramInfo.Values.Add(new Animation.KeyGroup() { AnimDataOffset = matanim.Constants[index].AnimDataOffset, Keys = keyGroup.Keys, }); } for (int curve = 0; curve < param.FloatCurveCount + param.IntCurveCount; curve++) { int index = curve + param.BeginCurve; Animation.KeyGroup keyGroup = CurveHelper.CreateTrack(matanim.Curves[index]); keyGroup.AnimDataOffset = matanim.Curves[index].AnimDataOffset; paramInfo.Values.Add(new Animation.KeyGroup() { AnimDataOffset = keyGroup.AnimDataOffset, Keys = keyGroup.Keys, }); } } foreach (TexturePatternAnimInfo SamplerInfo in matanim.TexturePatternAnimInfos) { BfresSamplerAnim sampler = new BfresSamplerAnim(SamplerInfo.Name, this, mat); mat.Samplers.Add(sampler); int textureIndex = 0; if (SamplerInfo.BeginConstant != 65535) { textureIndex = matanim.Constants[SamplerInfo.BeginConstant].Value; sampler.Keys.Add(new Animation.KeyFrame() { Frame = 0, Value = textureIndex }); sampler.Constant = true; sampler.AnimDataOffset = matanim.Constants[SamplerInfo.BeginConstant].AnimDataOffset; } if (SamplerInfo.CurveIndex != 65535) { int index = (int)SamplerInfo.CurveIndex; Animation.KeyGroup keyGroup = CurveHelper.CreateTrack(matanim.Curves[index]); sampler.AnimDataOffset = matanim.Curves[index].AnimDataOffset; sampler.Keys = keyGroup.Keys; } } } }
private void LoadAnim(TexPatternAnim anim) { CanReplace = true; CanExport = true; CanDelete = true; CanRename = true; Text = anim.Name; TexPatternAnim = anim; FrameCount = anim.FrameCount; Materials.Clear(); Textures.Clear(); if (anim.TextureRefNames != null) { foreach (var tex in anim.TextureRefNames) { Textures.Add(tex.Name); } } if (anim.TextureRefs != null) { foreach (var tex in anim.TextureRefs) { Textures.Add(tex.Key); } } foreach (TexPatternMatAnim matanim in anim.TexPatternMatAnims) { var mat = new MaterialAnimEntry(matanim.Name); mat.TexPatternMatAnim = matanim; Materials.Add(mat); foreach (PatternAnimInfo SamplerInfo in matanim.PatternAnimInfos) { BfresSamplerAnim sampler = new BfresSamplerAnim(SamplerInfo.Name, this); mat.Samplers.Add(sampler); int textureIndex = 0; if (SamplerInfo.SubBindIndex != -1) { textureIndex = SamplerInfo.SubBindIndex; sampler.Keys.Add(new Animation.KeyFrame() { Frame = 0, Value = textureIndex }); sampler.Constant = true; } if (SamplerInfo.CurveIndex != -1) { int index = (int)SamplerInfo.CurveIndex; Animation.KeyGroup keyGroup = CurveHelper.CreateTrackWiiU(matanim.Curves[index]); sampler.AnimDataOffset = matanim.Curves[index].AnimDataOffset; sampler.Keys = keyGroup.Keys; foreach (var ind in keyGroup.Keys) { Console.WriteLine($"{SamplerInfo.Name} {ind.Value}"); } } } } }