private void button1_Click(object sender, EventArgs e) { //try //{ mta = new MTA(); mta.Compile(new List <string>(richTextBox1.Text.Split('\n'))); using (var sfd = new SaveFileDialog()) { sfd.Filter = "Material Animation (.mta)|*.mta|" + "All Files (*.*)|*.*"; if (sfd.ShowDialog() == DialogResult.OK) { File.WriteAllBytes(sfd.FileName, mta.Rebuild()); } } //} /*catch (Exception ex) * { * throw; * Console.WriteLine(ex.ToString()); * MessageBox.Show("Failed to build MTA, make sure your formatting is correct", "MTA Build Error", MessageBoxButtons.OK, MessageBoxIcon.Error); * }*/ }
public void Import(object sender, EventArgs args) { using (OpenFileDialog fd = new OpenFileDialog()) { fd.Filter = "Supported Formats|*.omo;*.anim;*.chr0;*.smd;*.mta;|" + "Object Motion|*.omo|" + "Maya Animation|*.anim|" + "NW4R Animation|*.chr0|" + "Source Animation (SMD)|*.smd|" + "Smash 4 Material Animation (MTA)|*.mta|" + "All files(*.*)|*.*"; if (fd.ShowDialog() == DialogResult.OK) { foreach (string filename in fd.FileNames) { if (filename.EndsWith(".mta")) { MTA mta = new MTA(); try { mta.Read(filename); Runtime.MaterialAnimations.Add(filename, mta); Nodes.Add(filename); } catch (Exception) { mta = null; } } else if (filename.EndsWith(".smd")) { var anim = new Animation(filename); if (Runtime.TargetVBN == null) { Runtime.TargetVBN = new VBN(); } SMD.read(filename, anim, Runtime.TargetVBN); Nodes.Add(anim); } if (filename.EndsWith(".omo")) { Animation a = OMOOld.read(new FileData(filename)); a.Text = filename; Nodes.Add(a); } if (filename.EndsWith(".chr0")) { Nodes.Add(CHR0.read(new FileData(filename), Runtime.TargetVBN)); } if (filename.EndsWith(".anim")) { Nodes.Add(ANIM.read(filename, Runtime.TargetVBN)); } } } } }
private void addMaterialAnimation(string name, MTA m) { if (!Runtime.MaterialAnimations.ContainsValue(m) && !Runtime.MaterialAnimations.ContainsKey(name)) { Runtime.MaterialAnimations.Add(name, m); } viewports[0].loadMTA(m); mtaNode.Nodes.Add(name); }
private void loadViewportButton_Click(object sender, EventArgs e) { // Compile the MTA just in case and load into the active viewport. mta = new MTA(); mta.Compile(new List <string>(richTextBox1.Text.Split('\n'))); ModelViewport modelViewport = (ModelViewport)MainForm.Instance.GetActiveModelViewport(); if (modelViewport != null) { modelViewport.CurrentMaterialAnimation = mta; } }
public ModelContainer() { ImageKey = "folder"; SelectedImageKey = "folder"; nud = new NUD(); nut = new NUT(); mta = new MTA(); MOI = new MOI(); jtb = new JTB(); XMB = new XMBFile(); Checked = true; Refresh(); }
public void OpenMta(string pathMTA) { if (string.IsNullOrEmpty(pathMTA)) { return; } try { MTA = new MTA(); MTA.Read(pathMTA); } catch { MTA = null; } }
public void ImportAnimation(string filename) { if (filename.ToLower().EndsWith(".pac")) { PAC p = new PAC(); p.Read(filename); AnimationGroupNode animGroup = new AnimationGroupNode() { Text = filename }; string groupname = null; foreach (var pair in p.Files) { if (pair.Key.EndsWith(".omo")) { var anim = OMOOld.read(new FileData(pair.Value)); animGroup.Nodes.Add(anim); string AnimName = Regex.Match(pair.Key, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString(); if (!string.IsNullOrEmpty(AnimName)) { if (groupname == null) { groupname = pair.Key.Replace(AnimName, ""); } anim.Text = AnimName; } //Runtime.acmdEditor.updateCrcList(); } else if (pair.Key.EndsWith(".mta")) { MTA mta = new MTA(); mta.read(new FileData(pair.Value)); mta.Text = pair.Key; animGroup.Nodes.Add(mta); } } if (groupname != null && !groupname.Equals("")) { animGroup.UseGroupName = true; animGroup.Text = groupname; } treeView1.Nodes.Add(animGroup); } }
public void OpenPacs(List <string> pacs) { foreach (string pac in pacs) { PAC p = new PAC(); p.Read(pac); byte[] data; if (p.Files.TryGetValue("display", out data)) { MTA mta = new MTA(); mta.read(new FileData(data)); NUD.ApplyMta(mta, 0); } if (p.Files.TryGetValue("default.mta", out data)) { MTA mta = new MTA(); mta.read(new FileData(data)); NUD.ApplyMta(mta, 0); } } }
private void button2_Click(object sender, EventArgs e) { mta = new MTA(); mta.Compile(new List <string>(richTextBox1.Text.Split('\n'))); MainForm.Instance.viewports[0].loadMTA(mta); }
public MTAEditor(MTA Mta) { InitializeComponent(); mta = Mta; }
public MTAEditorGUI(MTA mta) { InitializeComponent(); this.mta = mta; }
private void button2_Click(object sender, EventArgs e) { mta = new MTA(); mta.Compile(new List <string>(richTextBox1.Text.Split('\n'))); }
public BFRES_FSHU(MTA mta, ShaderParamAnim fshu, ResFile b) { mta.Text = fshu.Name; mta.FrameCount = (uint)fshu.FrameCount; foreach (ShaderParamMatAnim matanim in fshu.ShaderParamMatAnims) { MatAnimEntry mat = new MatAnimEntry(); mat.Text = matanim.Name; Console.WriteLine($"MatAnim = {mat.Text}"); Console.WriteLine($"Curve Count = {matanim.Curves.Count}"); if (matanim.Curves.Count == 0) { } //First set the data then iterpolate foreach (AnimCurve cr in matanim.Curves) { mat.InterpolateWU(cr); } mta.matEntries.Add(mat); for (int Frame = 0; Frame < fshu.FrameCount; Frame++) { foreach (MatAnimData track in mat.matCurves) { AnimKey left = track.GetLeft(Frame); AnimKey right = track.GetRight(Frame); track.Value = Animation.Hermite(Frame, left.frame, right.frame, 0, 0, left.unk1, right.unk1); } } int CurCurve = 0; for (int Frame = 0; Frame < fshu.FrameCount; Frame++) { foreach (MatAnimData track in mat.matCurves) { //This works like this //Each param has their own info. While this loop through each curve determine which data is which //Set the param name. Then detemine the data in between begin curve and total count //Example. Begin curve starts at 0. Count may be 3 for RGB values //Then for next curve would start at 3 and so on //For color I simply use the values starting from RGBA //Then for the next param i subtract the start value to reset the index back to 0 foreach (ParamAnimInfo inf in matanim.ParamAnimInfos) { track.shaderParamName = inf.Name; if (inf.BeginCurve >= CurCurve) { if (inf.FloatCurveCount >= CurCurve) { int ColorIndex = CurCurve - inf.BeginCurve; track.AnimColorType = (MatAnimData.ColorType)ColorIndex; } } } } CurCurve++; } mta.matEntries.Add(mat); } }
//<summary> //Open an animation based on filename //</summary> public void openAnimation(string filename) { //Runtime.Animations.Clear(); if (filename.EndsWith(".mta")) { MTA mta = new MTA(); try { mta.Read(filename); Runtime.MaterialAnimations.Add(filename, mta); mtaNode.Nodes.Add(filename); MainForm.Instance.viewports[0].loadMTA(mta); Runtime.TargetMTAString = filename; } catch (EndOfStreamException) { mta = null; } } else if (filename.EndsWith(".smd")) { var anim = new SkelAnimation(); if (Runtime.TargetVBN == null) { Runtime.TargetVBN = new VBN(); } SMD.read(filename, anim, Runtime.TargetVBN); leftPanel.treeRefresh(); Runtime.Animations.Add(filename, anim); animNode.Nodes.Add(filename); } else if (filename.EndsWith(".pac")) { PAC p = new PAC(); p.Read(filename); foreach (var pair in p.Files) { if (pair.Key.EndsWith(".omo")) { var anim = OMO.read(new FileData(pair.Value)); string AnimName = Regex.Match(pair.Key, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString(); //AnimName = pair.Key; //AnimName = AnimName.Remove(AnimName.Length - 4); //AnimName = AnimName.Insert(3, "_"); if (!string.IsNullOrEmpty(AnimName)) { if (Runtime.Animations.ContainsKey(AnimName)) { Runtime.Animations[AnimName].children.Add(anim); } else { animNode.Nodes.Add(AnimName); Runtime.Animations.Add(AnimName, anim); } } else { if (Runtime.Animations.ContainsKey(pair.Key)) { Runtime.Animations[pair.Key].children.Add(anim); } else { animNode.Nodes.Add(pair.Key); Runtime.Animations.Add(pair.Key, anim); } } } else if (pair.Key.EndsWith(".mta")) { MTA mta = new MTA(); try { if (!Runtime.MaterialAnimations.ContainsKey(pair.Key)) { mta.read(new FileData(pair.Value)); Runtime.MaterialAnimations.Add(pair.Key, mta); mtaNode.Nodes.Add(pair.Key); } // matching string AnimName = Regex.Match(pair.Key, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString().Replace(".mta", ".omo"); if (Runtime.Animations.ContainsKey(AnimName)) { Runtime.Animations[AnimName].children.Add(mta); } } catch (EndOfStreamException) { mta = null; } } } } if (filename.EndsWith(".dat")) { if (!filename.EndsWith("AJ.dat")) { MessageBox.Show("Not a DAT animation"); } else { if (Runtime.ModelContainers[0].dat_melee == null) { MessageBox.Show("Load a DAT model first"); } else { DAT_Animation.LoadAJ(filename, Runtime.ModelContainers[0].dat_melee.bones); } } } //if (Runtime.TargetVBN.bones.Count > 0) //{ if (filename.EndsWith(".omo")) { Runtime.Animations.Add(filename, OMO.read(new FileData(filename))); animNode.Nodes.Add(filename); } if (filename.EndsWith(".chr0")) { Runtime.Animations.Add(filename, CHR0.read(new FileData(filename), Runtime.TargetVBN)); animNode.Nodes.Add(filename); } if (filename.EndsWith(".anim")) { Runtime.Animations.Add(filename, ANIM.read(filename, Runtime.TargetVBN)); animNode.Nodes.Add(filename); } }
private void openNud(string filename, string name = "") { string[] files = Directory.GetFiles(System.IO.Path.GetDirectoryName(filename)); string pnud = filename; string pnut = ""; string pjtb = ""; string pvbn = ""; string pmta = ""; string psb = ""; string pmoi = ""; List <string> pacs = new List <string>(); foreach (string s in files) { if (s.EndsWith(".nut")) { pnut = s; } if (s.EndsWith(".vbn")) { pvbn = s; } if (s.EndsWith(".jtb")) { pjtb = s; } if (s.EndsWith(".mta")) { pmta = s; } if (s.EndsWith(".sb")) { psb = s; } if (s.EndsWith(".moi")) { pmoi = s; } if (s.EndsWith(".pac")) { pacs.Add(s); } } ModelContainer model = new ModelContainer(); model.name = name; if (!pvbn.Equals("")) { model.vbn = new VBN(pvbn); Runtime.TargetVBN = model.vbn; if (!pjtb.Equals("")) { model.vbn.readJointTable(pjtb); } if (!psb.Equals("")) { model.vbn.swingBones.Read(psb); } } if (!pnut.Equals("")) { NUT nut = new NUT(pnut); Runtime.TextureContainers.Add(nut); } if (!pnud.Equals("")) { model.nud = new NUD(pnud); //AddDockedControl(new NUDMaterialEditor(model.nud.mesh[0].polygons[0].materials)); foreach (string s in pacs) { PAC p = new PAC(); p.Read(s); byte[] data; p.Files.TryGetValue("default.mta", out data); if (data != null) { MTA m = new MTA(); m.read(new FileData(data)); model.nud.applyMTA(m, 0); } } } if (!pmta.Equals("")) { try { model.mta = new MTA(); model.mta.Read(pmta); string mtaName = Path.Combine(Path.GetFileName(Path.GetDirectoryName(pmta)), Path.GetFileName(pmta)); Console.WriteLine($"MTA Name - {mtaName}"); addMaterialAnimation(mtaName, model.mta); } catch (EndOfStreamException) { model.mta = null; } } if (!pmoi.Equals("")) { model.moi = new MOI(pmoi); } if (model.nud != null) { model.nud.MergePoly(); } Runtime.ModelContainers.Add(model); meshList.refresh(); }