public void LoadSubFile(FMAA anim) { activeFmaa = anim; stPropertyGrid1.LoadProperty(anim.MaterialAnim, OnPropertyChanged); userDataEditor1.LoadUserData(anim.MaterialAnim.UserData); if (anim.AnimType == MaterialAnimation.AnimationType.TexturePattern) { } else { AnimParamEditor editor = (AnimParamEditor)GetActiveControl(typeof(AnimParamEditor)); if (editor == null) { stPanel2.Controls.Clear(); editor = new AnimParamEditor(); editor.Dock = DockStyle.Fill; stPanel2.Controls.Add(editor); } editor.LoadAnim(anim); editor.Refresh(); } }
private void AddMaterialAnims(ResFile resFile) { FmaaFolder fmaaFolder = new FmaaFolder(); Nodes.Add(fmaaFolder); foreach (var fmaa in resFile.MaterialAnims) { FMAA materialAnim = new FMAA(); materialAnim.Text = fmaa.Name; materialAnim.BFRESRender = BFRESRender; materialAnim.Read(fmaa); fmaaFolder.Nodes.Add(materialAnim); } }
public void LoadAnim(FMAA materialAnim) { if (materialAnim.Materials.Count <= 0) { return; } IsLoaded = false; ActiveMaterialAnim = materialAnim; materialCB.Items.Clear(); samplerCB.Items.Clear(); foreach (var mat in materialAnim.Materials) { materialCB.Items.Add(mat.Text); } materialCB.SelectedIndex = 0; material = materialAnim.Materials[materialCB.SelectedIndex]; if (material.Samplers.Count <= 0) { return; } foreach (var sampler in material.Samplers) { samplerCB.Items.Add(sampler.Text); } samplerCB.SelectedIndex = 0; activeSampler = (FMAA.BfresSamplerAnim)material.Samplers[samplerCB.SelectedIndex]; listViewCustom1.SuspendLayout(); listViewCustom1.Items.Clear(); LoadAniamtion(materialAnim, activeSampler); listViewCustom1.ResumeLayout(); IsLoaded = true; animationTrackBar.Value = 0; }
public GifToTexturePatternAnimation(string FileName, BNTX TargetBNTX, FMAA fmaa) { string TextureName = System.IO.Path.GetFileNameWithoutExtension(FileName); Image gifImg = Image.FromFile(FileName); //Add all the images var images = GetImages(gifImg); TargetBNTX.ImportTexture(images, TextureName); //Now load the key data to the animation fmaa.MaterialAnim = new Syroot.NintenTools.NSW.Bfres.MaterialAnim(); fmaa.MaterialAnim.Name = fmaa.Text; fmaa.MaterialAnim.Path = ""; fmaa.MaterialAnim.Loop = true; fmaa.MaterialAnim.FrameCount = images.Length; fmaa.MaterialAnim.TextureNames = new List <string>(); foreach (ImageKeyFrame key in images) { fmaa.MaterialAnim.TextureNames.Add($"{TextureName}{key.Frame}"); } var material = new MaterialAnimData(); material.Name = "NewMaterial"; material.TexturePatternAnimInfos = new List <TexturePatternAnimInfo>(); material.TexturePatternCurveIndex = 0; material.BeginVisalConstantIndex = 0; TexturePatternAnimInfo info = new TexturePatternAnimInfo(); info.CurveIndex = 0; info.SubBindIndex = -1; info.BeginConstant = ushort.MaxValue; info.Name = "_a0"; material.TexturePatternAnimInfos.Add(info); fmaa.MaterialAnim.MaterialAnimDataList.Add(material); AnimCurve curve = new AnimCurve(); curve.AnimDataOffset = 0; curve.CurveType = AnimCurveType.StepInt; curve.Delta = 0; curve.EndFrame = images.Length; curve.StartFrame = 0; curve.FrameType = AnimCurveFrameType.Byte; curve.Scale = 1; curve.Offset = 0; curve.Frames = new float[(int)curve.EndFrame]; for (int i = 0; i < curve.EndFrame; i++) { curve.Frames[i] = images[i].Frame; } curve.Keys = new float[(int)curve.Frames.Length, 1]; for (int i = 0; i < (ushort)curve.Keys.Length; i++) { int index = fmaa.MaterialAnim.TextureNames.IndexOf($"{TextureName}{images[i].Frame}"); curve.Keys[i, 0] = index; } material.Curves.Add(curve); fmaa.UpdateMaterialBinds(); }